本文整理汇总了C++中pmap_extract函数的典型用法代码示例。如果您正苦于以下问题:C++ pmap_extract函数的具体用法?C++ pmap_extract怎么用?C++ pmap_extract使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pmap_extract函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: _bus_dmamap_load_vaddr
int
_bus_dmamap_load_vaddr(bus_dma_tag_t t, bus_dmamap_t map,
void *buf, bus_size_t size, pmap_t pmap)
{
vaddr_t vaddr;
paddr_t paddr;
vaddr_t next, end;
int error;
vaddr = (vaddr_t)buf;
end = vaddr + size;
if (pmap == pmap_kernel() &&
vaddr >= SH3_P1SEG_BASE && end <= SH3_P2SEG_END)
paddr = SH3_P1SEG_TO_PHYS(vaddr);
else {
for (next = (vaddr + PAGE_SIZE) & ~PAGE_MASK;
next < end; next += PAGE_SIZE) {
pmap_extract(pmap, vaddr, &paddr);
error = _bus_dmamap_load_paddr(t, map,
paddr, vaddr, next - vaddr);
if (error != 0)
return (error);
vaddr = next;
}
pmap_extract(pmap, vaddr, &paddr);
size = end - vaddr;
}
return (_bus_dmamap_load_paddr(t, map, paddr, vaddr, size));
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:33,代码来源:bus_dma.c
示例2: vmapbuf
/*
* Map a user I/O request into kernel virtual address space.
* Note: the pages are already locked by uvm_vslock(), so we
* do not need to pass an access_type to pmap_enter().
*/
int
vmapbuf(struct buf *bp, vsize_t len)
{
struct pmap *upmap;
vaddr_t uva; /* User VA (map from) */
vaddr_t kva; /* Kernel VA (new to) */
paddr_t pa; /* physical address */
vsize_t off;
if ((bp->b_flags & B_PHYS) == 0)
panic("vmapbuf");
bp->b_saveaddr = bp->b_data;
uva = trunc_page((vaddr_t)bp->b_data);
off = (vaddr_t)bp->b_data - uva;
len = round_page(off + len);
kva = uvm_km_alloc(kernel_map, len, 0, UVM_KMF_VAONLY | UVM_KMF_WAITVA);
bp->b_data = (void *)(kva + off);
upmap = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map);
do {
if (pmap_extract(upmap, uva, &pa) == FALSE)
panic("vmapbuf: null page frame");
/* Now map the page into kernel space. */
pmap_kenter_pa(kva, pa, VM_PROT_READ | VM_PROT_WRITE, 0);
uva += PAGE_SIZE;
kva += PAGE_SIZE;
len -= PAGE_SIZE;
} while (len);
pmap_update(pmap_kernel());
return 0;
}
开发者ID:yazshel,项目名称:netbsd-kernel,代码行数:39,代码来源:vm_machdep.c
示例3: vmapbuf
/*
* Map an IO request into kernel virtual address space.
*/
void
vmapbuf(struct buf *bp, vsize_t len)
{
vaddr_t faddr, taddr, off;
paddr_t pa;
#ifdef DIAGNOSTIC
if (!(bp->b_flags & B_PHYS))
panic("vmapbuf");
#endif
faddr = trunc_page((vaddr_t)(bp->b_saveaddr = bp->b_data));
off = (vaddr_t)bp->b_data - faddr;
len = round_page(off + len);
taddr = uvm_km_valloc_wait(phys_map, len);
bp->b_data = (caddr_t)(taddr + off);
for (; len > 0; len -= NBPG) {
pmap_extract(vm_map_pmap(&bp->b_proc->p_vmspace->vm_map),
faddr, &pa);
pmap_enter(vm_map_pmap(phys_map), taddr, pa,
VM_PROT_READ | VM_PROT_WRITE, PMAP_WIRED);
faddr += NBPG;
taddr += NBPG;
}
pmap_update(vm_map_pmap(phys_map));
}
开发者ID:alenichev,项目名称:openbsd-kernel,代码行数:28,代码来源:vm_machdep.c
示例4: sparse_dump_mark
/*
* Include or exclude pages in a sparse dump, by half-open virtual
* address interval (which may wrap around the end of the space).
*/
static void
sparse_dump_mark(vaddr_t vbegin, vaddr_t vend, int includep)
{
pmap_t pmap;
paddr_t p;
vaddr_t v;
/*
* If a partial page is called for, the whole page must be included.
*/
if (includep) {
vbegin = rounddown(vbegin, PAGE_SIZE);
vend = roundup(vend, PAGE_SIZE);
} else {
vbegin = roundup(vbegin, PAGE_SIZE);
vend = rounddown(vend, PAGE_SIZE);
}
pmap = pmap_kernel();
for (v = vbegin; v != vend; v += PAGE_SIZE) {
if (pmap_extract(pmap, v, &p)) {
if (includep)
setbit(sparse_dump_physmap, p/PAGE_SIZE);
else
clrbit(sparse_dump_physmap, p/PAGE_SIZE);
}
}
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:32,代码来源:dumpsys.c
示例5: viommu_enter
/*
* Add an entry to the IOMMU table.
*/
void
viommu_enter(struct iommu_state *is, struct strbuf_ctl *sb, bus_addr_t va,
paddr_t pa, int flags)
{
u_int64_t tsbid = IOTSBSLOT(va, is->is_tsbsize);
paddr_t page_list[1], addr;
u_int64_t attr, nmapped;
int err;
KASSERT(sb == NULL);
#ifdef DIAGNOSTIC
if (va < is->is_dvmabase || (va + PAGE_MASK) > is->is_dvmaend)
panic("viommu_enter: va %#lx not in DVMA space", va);
#endif
attr = PCI_MAP_ATTR_READ | PCI_MAP_ATTR_WRITE;
if (flags & BUS_DMA_READ)
attr &= ~PCI_MAP_ATTR_READ;
if (flags & BUS_DMA_WRITE)
attr &= ~PCI_MAP_ATTR_WRITE;
page_list[0] = trunc_page(pa);
if (!pmap_extract(pmap_kernel(), (vaddr_t)page_list, &addr))
panic("viommu_enter: pmap_extract failed");
err = hv_pci_iommu_map(is->is_devhandle, tsbid, 1, attr,
addr, &nmapped);
if (err != H_EOK || nmapped != 1)
panic("hv_pci_iommu_map: err=%d", err);
}
开发者ID:alenichev,项目名称:openbsd-kernel,代码行数:33,代码来源:viommu.c
示例6: vmapbuf
/*
* Map an IO request into kernel virtual address space.
*/
void
vmapbuf(struct buf *bp, vsize_t len)
{
struct pmap *pm = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map);
vaddr_t kva, uva;
vsize_t size, off;
#ifdef DIAGNOSTIC
if ((bp->b_flags & B_PHYS) == 0)
panic("vmapbuf");
#endif
bp->b_saveaddr = bp->b_data;
uva = trunc_page((vaddr_t)bp->b_data);
off = (vaddr_t)bp->b_data - uva;
size = round_page(off + len);
kva = uvm_km_valloc_prefer_wait(phys_map, size, uva);
bp->b_data = (caddr_t)(kva + off);
while (size > 0) {
paddr_t pa;
if (pmap_extract(pm, uva, &pa) == FALSE)
panic("vmapbuf: null page frame");
else
pmap_kenter_pa(kva, pa, UVM_PROT_RW);
uva += PAGE_SIZE;
kva += PAGE_SIZE;
size -= PAGE_SIZE;
}
pmap_update(pmap_kernel());
}
开发者ID:alenichev,项目名称:openbsd-kernel,代码行数:34,代码来源:vm_machdep.c
示例7: videommap
paddr_t
videommap(dev_t dev, off_t off, int prot)
{
struct video_softc *sc;
int unit;
caddr_t p;
paddr_t pa;
DPRINTF(("%s: off=%d, prot=%d\n", __func__, off, prot));
unit = VIDEOUNIT(dev);
if (unit >= video_cd.cd_ndevs ||
(sc = video_cd.cd_devs[unit]) == NULL)
return (-1);
if (sc->sc_dying)
return (-1);
if (sc->hw_if->mappage == NULL)
return (-1);
p = sc->hw_if->mappage(sc->hw_hdl, off, prot);
if (p == NULL)
return (-1);
if (pmap_extract(pmap_kernel(), (vaddr_t)p, &pa) == FALSE)
panic("videommap: invalid page");
sc->sc_vidmode = VIDMODE_MMAP;
return (pa);
}
开发者ID:alenichev,项目名称:openbsd-kernel,代码行数:30,代码来源:video.c
示例8: vmapbuf
/*
* Map a user I/O request into kernel virtual address space.
* Note: the pages are already locked by uvm_vslock(), so we
* do not need to pass an access_type to pmap_enter().
*/
void
vmapbuf(struct buf *bp, vsize_t len)
{
vaddr_t faddr, taddr, off;
paddr_t fpa;
if ((bp->b_flags & B_PHYS) == 0)
panic("vmapbuf");
faddr = trunc_page((vaddr_t)(bp->b_saveaddr = bp->b_data));
off = (vaddr_t)bp->b_data - faddr;
len = round_page(off + len);
taddr= uvm_km_valloc_wait(phys_map, len);
bp->b_data = (caddr_t)(taddr + off);
/*
* The region is locked, so we expect that pmap_pte() will return
* non-NULL.
* XXX: unwise to expect this in a multithreaded environment.
* anything can happen to a pmap between the time we lock a
* region, release the pmap lock, and then relock it for
* the pmap_extract().
*
* no need to flush TLB since we expect nothing to be mapped
* where we we just allocated (TLB will be flushed when our
* mapping is removed).
*/
while (len) {
(void) pmap_extract(vm_map_pmap(&bp->b_proc->p_vmspace->vm_map),
faddr, &fpa);
pmap_kenter_pa(taddr, fpa, PROT_READ | PROT_WRITE);
faddr += PAGE_SIZE;
taddr += PAGE_SIZE;
len -= PAGE_SIZE;
}
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:39,代码来源:vm_machdep.c
示例9: obio_iomem_unmap
void
obio_iomem_unmap(void *v, bus_space_handle_t bsh, bus_size_t size)
{
u_long va, endva;
bus_addr_t bpa;
if (bsh >= SH3_P2SEG_BASE && bsh <= SH3_P2SEG_END) {
/* maybe CS0,1,2,3,4,7 */
return;
}
/* CS5,6 */
va = trunc_page(bsh);
endva = round_page(bsh + size);
#ifdef DIAGNOSTIC
if (endva <= va)
panic("obio_io_unmap: overflow");
#endif
pmap_extract(pmap_kernel(), va, &bpa);
bpa += bsh & PGOFSET;
pmap_kremove(va, endva - va);
/*
* Free the kernel virtual mapping.
*/
uvm_km_free(kernel_map, va, endva - va);
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:30,代码来源:obio.c
示例10: vmapbuf
/*
* Map a user I/O request into kernel virtual address space.
*/
int
vmapbuf(struct buf *bp, vsize_t len)
{
vaddr_t kva; /* Kernel VA (new to) */
if ((bp->b_flags & B_PHYS) == 0)
panic("vmapbuf");
vaddr_t uva = mips_trunc_page(bp->b_data);
const vaddr_t off = (vaddr_t)bp->b_data - uva;
len = mips_round_page(off + len);
kva = uvm_km_alloc(phys_map, len, atop(uva) & uvmexp.colormask,
UVM_KMF_VAONLY | UVM_KMF_WAITVA | UVM_KMF_COLORMATCH);
KASSERT((atop(kva ^ uva) & uvmexp.colormask) == 0);
bp->b_saveaddr = bp->b_data;
bp->b_data = (void *)(kva + off);
struct pmap * const upmap = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map);
do {
paddr_t pa; /* physical address */
if (pmap_extract(upmap, uva, &pa) == false)
panic("vmapbuf: null page frame");
pmap_kenter_pa(kva, pa, VM_PROT_READ | VM_PROT_WRITE,
PMAP_WIRED);
uva += PAGE_SIZE;
kva += PAGE_SIZE;
len -= PAGE_SIZE;
} while (len);
pmap_update(pmap_kernel());
return 0;
}
开发者ID:eyberg,项目名称:rumpkernel-netbsd-src,代码行数:35,代码来源:vm_machdep.c
示例11: vmapbuf
/* This code was originally stolen from the alpha port. */
int
vmapbuf(struct buf *bp, vsize_t len)
{
vaddr_t faddr, taddr, off;
paddr_t pa;
struct proc *p;
vm_prot_t prot;
if ((bp->b_flags & B_PHYS) == 0)
panic("vmapbuf");
p = bp->b_proc;
bp->b_saveaddr = bp->b_data;
faddr = trunc_page((vaddr_t)bp->b_data);
off = (vaddr_t)bp->b_data - faddr;
len = round_page(off + len);
taddr = uvm_km_alloc(phys_map, len, 0, UVM_KMF_VAONLY | UVM_KMF_WAITVA);
bp->b_data = (void *)(taddr + off);
len = atop(len);
prot = bp->b_flags & B_READ ? VM_PROT_READ | VM_PROT_WRITE :
VM_PROT_READ;
while (len--) {
if (pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), faddr,
&pa) == false)
panic("vmapbuf: null page frame");
pmap_enter(vm_map_pmap(phys_map), taddr, trunc_page(pa),
prot, prot | PMAP_WIRED);
faddr += PAGE_SIZE;
taddr += PAGE_SIZE;
}
pmap_update(vm_map_pmap(phys_map));
return 0;
}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:34,代码来源:vm_machdep.c
示例12: mappedcopyout
int
mappedcopyout(void *f, void *t, size_t count)
{
void *fromp = f, *top = t;
vaddr_t kva;
paddr_t upa;
size_t len;
int off, alignable;
pmap_t upmap;
#define CADDR2 caddr1
#ifdef DEBUG
if (mappedcopydebug & MDB_COPYOUT)
printf("mappedcopyout(%p, %p, %lu), pid %d\n",
fromp, top, (u_long)count, curproc->p_pid);
mappedcopyoutcount++;
#endif
if (CADDR2 == 0)
CADDR2 = (void *) uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
UVM_KMF_VAONLY);
kva = (vaddr_t) CADDR2;
off = (int)((u_long)top & PAGE_MASK);
alignable = (off == ((u_long)fromp & PAGE_MASK));
upmap = vm_map_pmap(&curproc->p_vmspace->vm_map);
while (count > 0) {
/*
* First access of a page, use subyte to make sure
* page is faulted in and write access allowed.
*/
if (subyte(top, *((char *)fromp)) == -1)
return EFAULT;
/*
* Map in the page and memcpy data out to it
*/
if (pmap_extract(upmap, trunc_page((vaddr_t)top), &upa)
== false)
panic("mappedcopyout: null page frame");
len = min(count, (PAGE_SIZE - off));
pmap_enter(pmap_kernel(), kva, upa,
VM_PROT_READ|VM_PROT_WRITE,
VM_PROT_READ|VM_PROT_WRITE|PMAP_WIRED);
pmap_update(pmap_kernel());
if (len == PAGE_SIZE && alignable && off == 0)
copypage(fromp, (void *)kva);
else
memcpy((void *)(kva + off), fromp, len);
fromp += len;
top += len;
count -= len;
off = 0;
}
pmap_remove(pmap_kernel(), kva, kva + PAGE_SIZE);
pmap_update(pmap_kernel());
return 0;
#undef CADDR2
}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:58,代码来源:mappedcopy.c
示例13: RealView_framebuffer_init
void RealView_framebuffer_init(void)
{
gRealviewPl111Base = ml_io_map(REALVIEW_PL111_BASE, PAGE_SIZE);
/*
* The hardware demands a framebuffer, but the framebuffer has to be given
* in a hardware address.
*/
void *framebuffer = pmap_steal_memory(1024 * 768 * 4);
void *framebuffer_phys = pmap_extract(kernel_pmap, framebuffer);
uint32_t depth = 2;
uint32_t width = 1024;
uint32_t height = 768;
uint32_t pitch = (width * depth);
uint32_t fb_length = (pitch * width);
uint32_t timingRegister, controlRegister;
/*
* Set framebuffer address
*/
HARDWARE_REGISTER(gRealviewPl111Base + PL111_UPPER_FB) = framebuffer_phys;
HARDWARE_REGISTER(gRealviewPl111Base + PL111_LOWER_FB) = framebuffer_phys;
/*
* Initialize timings to 1024x768x16
*/
HARDWARE_REGISTER(gRealviewPl111Base + PL111_TIMINGS_0) = LCDTIMING0_PPL(width);
HARDWARE_REGISTER(gRealviewPl111Base + PL111_TIMINGS_1) = LCDTIMING1_LPP(height);
/*
* Enable the TFT/LCD Display
*/
HARDWARE_REGISTER(gRealviewPl111Base + PL111_CONTROL) = LCDCONTROL_LCDEN | LCDCONTROL_LCDTFT | LCDCONTROL_LCDPWR | LCDCONTROL_LCDBPP(5);
PE_state.video.v_baseAddr = (unsigned long) framebuffer_phys;
PE_state.video.v_rowBytes = width * 4;
PE_state.video.v_width = width;
PE_state.video.v_height = height;
PE_state.video.v_depth = 4 * (8); // 16bpp
kprintf(KPRINTF_PREFIX "framebuffer initialized\n");
bzero(framebuffer, (pitch * height));
char tempbuf[16];
if (PE_parse_boot_argn("-graphics-mode", tempbuf, sizeof(tempbuf))) {
/*
* BootX like framebuffer.
*/
memset(framebuffer, 0xb9, PE_state.video.v_rowBytes * PE_state.video.v_height);
initialize_screen((void *) &PE_state.video, kPEGraphicsMode);
} else {
initialize_screen((void *) &PE_state.video, kPETextMode);
}
}
开发者ID:armv8,项目名称:xnu,代码行数:58,代码来源:pe_realview.c
示例14: trunc_page
/*
* Create writeable aliases of memory we need
* to write to as kernel is mapped read-only
*/
void *codepatch_maprw(vaddr_t *nva, vaddr_t dest)
{
paddr_t kva = trunc_page((paddr_t)dest);
paddr_t po = (paddr_t)dest & PAGE_MASK;
paddr_t pa1, pa2;
if (*nva == 0)
*nva = (vaddr_t)km_alloc(2 * PAGE_SIZE, &kv_any, &kp_none,
&kd_waitok);
pmap_extract(pmap_kernel(), kva, &pa1);
pmap_extract(pmap_kernel(), kva + PAGE_SIZE, &pa2);
pmap_kenter_pa(*nva, pa1, PROT_READ | PROT_WRITE);
pmap_kenter_pa(*nva + PAGE_SIZE, pa2, PROT_READ | PROT_WRITE);
pmap_update(pmap_kernel());
return (void *)(*nva + po);
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:22,代码来源:codepatch.c
示例15: kvtop
/*
* Convert kernel VA to physical address
*/
int
kvtop(caddr_t addr)
{
paddr_t pa;
if (pmap_extract(pmap_kernel(), (vaddr_t)addr, &pa) == FALSE)
panic("kvtop: zero page frame");
return((int)pa);
}
开发者ID:avsm,项目名称:openbsd-xen-sys,代码行数:12,代码来源:vm_machdep.c
示例16: boot_map
static vm_offset_t
boot_map(
void * data, /* private data */
vm_offset_t offset) /* offset to map */
{
vm_offset_t start_offset = (vm_offset_t) data;
return pmap_extract(kernel_pmap, start_offset + offset);
}
开发者ID:sebastianscatularo,项目名称:gnumach,代码行数:9,代码来源:bootstrap.c
示例17: getphysmem
static paddr_t
getphysmem(u_long size)
{
struct memarr *pmemarr; /* physical memory regions */
int npmemarr; /* number of entries in pmemarr */
struct memarr *mp;
int i;
extern char start[]; /* top of stack (see srt0.S) */
/*
* Find the physical memory area that's in use by the boot loader.
* Our stack grows down from label `start'; assume we need no more
* than 16K of stack space.
* The top of the boot loader is the next 4MB boundary.
*/
if (pmap_extract((vaddr_t)start - (16*1024), &bstart) != 0)
return ((paddr_t)-1);
bend = roundup(bstart, 0x400000);
/*
* Get available physical memory from the prom.
*/
npmemarr = prom_makememarr(NULL, 0, MEMARR_AVAILPHYS);
pmemarr = alloc(npmemarr*sizeof(struct memarr));
if (pmemarr == NULL)
return ((paddr_t)-1);
npmemarr = prom_makememarr(pmemarr, npmemarr, MEMARR_AVAILPHYS);
/*
* Find a suitable loading address.
*/
for (mp = pmemarr, i = npmemarr; --i >= 0; mp++) {
paddr_t pa = (paddr_t)pmemarr[i].addr;
u_long len = (u_long)pmemarr[i].len;
/* Check whether it will fit in front of us */
if (pa < bstart && len >= size && (bstart - pa) >= size)
return (pa);
/* Skip the boot program memory */
if (pa < bend) {
if (len < bend - pa)
/* Not large enough */
continue;
/* Shrink this segment */
len -= bend - pa;
pa = bend;
}
/* Does it fit in the remainder of this segment? */
if (len >= size)
return (pa);
}
return ((paddr_t)-1);
}
开发者ID:yazshel,项目名称:netbsd-kernel,代码行数:57,代码来源:boot.c
示例18: kvtop
/*
* Convert kernel VA to physical address
*/
int
kvtop(void *addr)
{
paddr_t pa;
if (pmap_extract(pmap_kernel(), (vaddr_t)addr, &pa) == false)
panic("kvtop: zero page frame");
return (int)pa;
}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:12,代码来源:vm_machdep.c
示例19: ldc_reset
void
ldc_reset(struct ldc_conn *lc)
{
int err;
vaddr_t va;
paddr_t pa;
DPRINTF(("Resetting connection\n"));
mutex_enter(&lc->lc_txq->lq_mtx);
#if OPENBSD_BUSDMA
err = hv_ldc_tx_qconf(lc->lc_id,
lc->lc_txq->lq_map->dm_segs[0].ds_addr, lc->lc_txq->lq_nentries);
#else
va = lc->lc_txq->lq_va;
pa = 0;
if (pmap_extract(pmap_kernel(), va, &pa) == FALSE)
panic("pmap_extract failed %lx\n", va);
err = hv_ldc_tx_qconf(lc->lc_id, pa, lc->lc_txq->lq_nentries);
#endif
if (err != H_EOK)
printf("%s: hv_ldc_tx_qconf %d\n", __func__, err);
#if OPENBSD_BUSDMA
err = hv_ldc_rx_qconf(lc->lc_id,
lc->lc_rxq->lq_map->dm_segs[0].ds_addr, lc->lc_rxq->lq_nentries);
#else
va = lc->lc_rxq->lq_va;
pa = 0;
if (pmap_extract(pmap_kernel(), va, &pa) == FALSE)
panic("pmap_extract failed %lx\n", va);
err = hv_ldc_tx_qconf(lc->lc_id, pa, lc->lc_rxq->lq_nentries);
#endif
if (err != H_EOK)
printf("%s: hv_ldc_rx_qconf %d\n", __func__, err);
lc->lc_tx_seqid = 0;
lc->lc_state = 0;
lc->lc_tx_state = lc->lc_rx_state = LDC_CHANNEL_DOWN;
mutex_exit(&lc->lc_txq->lq_mtx);
lc->lc_reset(lc);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:44,代码来源:ldc.c
示例20: _isa_dma_check_buffer
/*
* Return 0 if all pages in the passed buffer lie within the DMA'able
* range RAM.
*/
int
_isa_dma_check_buffer(void *buf, buf_size_t buflen, int segcnt,
buf_size_t boundary, struct proc *p)
{
vaddr_t vaddr = (vaddr_t)buf;
vaddr_t endva;
paddr_t pa, lastpa;
u_long pagemask = ~(boundary - 1);
pmap_t pmap;
int nsegs;
endva = round_page(vaddr + buflen);
nsegs = 1;
lastpa = 0;
if (p != NULL)
pmap = p->p_vmspace->vm_map.pmap;
else
pmap = pmap_kernel();
for (; vaddr < endva; vaddr += NBPG) {
/*
* Get physical address for this segment.
*/
pmap_extract(pmap, (vaddr_t)vaddr, &pa);
pa = trunc_page(pa);
/*
* Is it below the DMA'able threshold?
*/
if (pa > ISA_DMA_BOUNCE_THRESHOLD)
return (EINVAL);
if (lastpa) {
/*
* Check excessive segment count.
*/
if (lastpa + NBPG != pa) {
if (++nsegs > segcnt)
return (EFBIG);
}
/*
* Check boundary restriction.
*/
if (boundary) {
if ((lastpa ^ pa) & pagemask)
return (EINVAL);
}
}
lastpa = pa;
}
return (0);
}
开发者ID:avsm,项目名称:openbsd-xen-sys,代码行数:60,代码来源:isa_machdep.c
注:本文中的pmap_extract函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论