/* * Common functin for mmap(2)'ing DMA-safe memory. May be called by * bus-specific DMA mmap(2)'ing functions. */ paddr_t _bus_dmamem_mmap(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, off_t off, int prot, int flags) { int i; for (i = 0; i < nsegs; i++) { #ifdef DIAGNOSTIC if (off & PGOFSET) panic("_bus_dmamem_mmap: offset unaligned"); if (segs[i].ds_addr & PGOFSET) panic("_bus_dmamem_mmap: segment unaligned"); if (segs[i].ds_len & PGOFSET) panic("_bus_dmamem_mmap: segment size not multiple" " of page size"); #endif if (off >= segs[i].ds_len) { off -= segs[i].ds_len; continue; } /* * XXXSCW: What about BUS_DMA_COHERENT ?? */ return m68k_btop((char *)segs[i].ds_addr + off); } /* Page not found. */ return -1; }
paddr_t grfmmap(dev_t dev, off_t off, int prot) { struct grf_softc *sc; struct macfb_devconfig *dc; int unit = GRFUNIT(dev); if (grf_softc == NULL || unit >= numgrf) return ENXIO; sc = &grf_softc[unit]; if (sc->mfb_sc == NULL) return ENXIO; dc = sc->mfb_sc->sc_dc; if ((u_int)off < m68k_round_page(dc->dc_offset + dc->dc_size)) return m68k_btop(dc->dc_paddr + off); return (-1); }
paddr_t mmmmap(dev_t dev, off_t off, int prot) { /* * /dev/mem is the only one that makes sense through this * interface. For /dev/kmem any physaddr we return here * could be transient and hence incorrect or invalid at * a later time. /dev/null just doesn't make any sense * and /dev/zero is a hack that is handled via the default * pager in mmap(). */ if (minor(dev) != DEV_MEM) return -1; /* * Allow access only in RAM. */ if ((u_int)off < lowram || (u_int)off >= 0xFFFFFFFC) return -1; return m68k_btop((u_int)off); }