From: jsg Date: Wed, 20 Mar 2024 02:42:17 +0000 (+0000) Subject: add vmap_pfn() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c036ab1656490febf4f67341ec7871139e9c7103;p=openbsd add vmap_pfn() --- diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c index 7e548a78493..efe42503e83 100644 --- a/sys/dev/pci/drm/drm_linux.c +++ b/sys/dev/pci/drm/drm_linux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_linux.c,v 1.110 2024/03/20 02:38:35 jsg Exp $ */ +/* $OpenBSD: drm_linux.c,v 1.111 2024/03/20 02:42:17 jsg Exp $ */ /* * Copyright (c) 2013 Jonathan Gray * Copyright (c) 2015, 2016 Mark Kettenis @@ -673,6 +673,28 @@ vmap(struct vm_page **pages, unsigned int npages, unsigned long flags, return (void *)va; } +void * +vmap_pfn(unsigned long *pfns, unsigned int npfn, pgprot_t prot) +{ + vaddr_t va; + paddr_t pa; + int i; + + va = (vaddr_t)km_alloc(PAGE_SIZE * npfn, &kv_any, &kp_none, + &kd_nowait); + if (va == 0) + return NULL; + for (i = 0; i < npfn; i++) { + pa = round_page(pfns[i]) | prot; + pmap_enter(pmap_kernel(), va + (i * PAGE_SIZE), pa, + PROT_READ | PROT_WRITE, + PROT_READ | PROT_WRITE | PMAP_WIRED); + pmap_update(pmap_kernel()); + } + + return (void *)va; +} + void vunmap(void *addr, size_t size) { diff --git a/sys/dev/pci/drm/include/linux/vmalloc.h b/sys/dev/pci/drm/include/linux/vmalloc.h index e2b4fa0115f..f3f4ae2fdd6 100644 --- a/sys/dev/pci/drm/include/linux/vmalloc.h +++ b/sys/dev/pci/drm/include/linux/vmalloc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmalloc.h,v 1.6 2024/01/16 23:38:13 jsg Exp $ */ +/* $OpenBSD: vmalloc.h,v 1.7 2024/03/20 02:42:17 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * @@ -25,6 +25,7 @@ #include /* for pgprot_t */ void *vmap(struct vm_page **, unsigned int, unsigned long, pgprot_t); +void *vmap_pfn(unsigned long *, unsigned int, pgprot_t); void vunmap(void *, size_t); static inline void *