xref: /dflybsd-src/sys/dev/drm/include/linux/highmem.h (revision f0bba3d1dd5ba7adfae61269b5424d4ad443ab97)
19a90aa3dSFrançois Tigeot /*
2*f0bba3d1SFrançois Tigeot  * Copyright (c) 2014-2018 François Tigeot <ftigeot@wolfpond.org>
39a90aa3dSFrançois Tigeot  * All rights reserved.
49a90aa3dSFrançois Tigeot  *
59a90aa3dSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
69a90aa3dSFrançois Tigeot  * modification, are permitted provided that the following conditions
79a90aa3dSFrançois Tigeot  * are met:
89a90aa3dSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
99a90aa3dSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
109a90aa3dSFrançois Tigeot  *    disclaimer.
119a90aa3dSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
129a90aa3dSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
139a90aa3dSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
149a90aa3dSFrançois Tigeot  *
159a90aa3dSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
169a90aa3dSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
179a90aa3dSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
189a90aa3dSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
199a90aa3dSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
209a90aa3dSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
219a90aa3dSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
229a90aa3dSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
239a90aa3dSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
249a90aa3dSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
259a90aa3dSFrançois Tigeot  */
269a90aa3dSFrançois Tigeot 
279a90aa3dSFrançois Tigeot #ifndef _LINUX_HIGHMEM_H_
289a90aa3dSFrançois Tigeot #define _LINUX_HIGHMEM_H_
299a90aa3dSFrançois Tigeot 
309a90aa3dSFrançois Tigeot #include <machine/vmparam.h>
319a90aa3dSFrançois Tigeot 
326431cd91SFrançois Tigeot #include <linux/kernel.h>
336431cd91SFrançois Tigeot #include <linux/bug.h>
346431cd91SFrançois Tigeot #include <linux/mm.h>
3501b43122SFrançois Tigeot #include <linux/uaccess.h>
361334141fSFrançois Tigeot #include <linux/hardirq.h>
3701b43122SFrançois Tigeot 
38b86cbe23SFrançois Tigeot #include <asm/cacheflush.h>
39b86cbe23SFrançois Tigeot 
40*f0bba3d1SFrançois Tigeot static inline struct page *
416e31eb98SFrançois Tigeot kmap_to_page(void *addr)
426e31eb98SFrançois Tigeot {
43*f0bba3d1SFrançois Tigeot 	return (struct page *)PHYS_TO_VM_PAGE(vtophys(addr));
446e31eb98SFrançois Tigeot }
456e31eb98SFrançois Tigeot 
46*f0bba3d1SFrançois Tigeot static inline void *kmap(struct page *pg)
479a90aa3dSFrançois Tigeot {
48*f0bba3d1SFrançois Tigeot 	return (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS( (struct vm_page *)pg ));
499a90aa3dSFrançois Tigeot }
509a90aa3dSFrançois Tigeot 
51*f0bba3d1SFrançois Tigeot static inline void kunmap(struct page *pg)
52e3440f96SFrançois Tigeot {
53e3440f96SFrançois Tigeot 	/* Nothing to do on systems with a direct memory map */
54e3440f96SFrançois Tigeot }
55e3440f96SFrançois Tigeot 
56*f0bba3d1SFrançois Tigeot static inline void *kmap_atomic(struct page *pg)
57e3440f96SFrançois Tigeot {
58*f0bba3d1SFrançois Tigeot 	return (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS( (struct vm_page *)pg ));
59e3440f96SFrançois Tigeot }
60e3440f96SFrançois Tigeot 
61e3440f96SFrançois Tigeot static inline void kunmap_atomic(void *vaddr)
629a90aa3dSFrançois Tigeot {
639a90aa3dSFrançois Tigeot 	/* Nothing to do on systems with a direct memory map */
649a90aa3dSFrançois Tigeot }
659a90aa3dSFrançois Tigeot 
669a90aa3dSFrançois Tigeot #endif	/* _LINUX_HIGHMEM_H_ */
67