-/* $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 <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
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)
{
-/* $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
*
#include <linux/types.h> /* 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 *