xref: /dflybsd-src/sys/dev/drm/include/linux/highmem.h (revision 1ca9f5d2f795150c40d708639e177f4ea8600e66)
19a90aa3dSFrançois Tigeot /*
2f0bba3d1SFranç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 
40f0bba3d1SFrançois Tigeot static inline struct page *
416e31eb98SFrançois Tigeot kmap_to_page(void *addr)
426e31eb98SFrançois Tigeot {
43f0bba3d1SFrançois Tigeot 	return (struct page *)PHYS_TO_VM_PAGE(vtophys(addr));
446e31eb98SFrançois Tigeot }
456e31eb98SFrançois Tigeot 
46f0bba3d1SFrançois Tigeot static inline void *kmap(struct page *pg)
479a90aa3dSFrançois Tigeot {
48f0bba3d1SFrançois Tigeot 	return (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS( (struct vm_page *)pg ));
499a90aa3dSFrançois Tigeot }
509a90aa3dSFrançois Tigeot 
51f0bba3d1SFranç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 
56f0bba3d1SFrançois Tigeot static inline void *kmap_atomic(struct page *pg)
57e3440f96SFrançois Tigeot {
58f0bba3d1SFrançois Tigeot 	return (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS( (struct vm_page *)pg ));
59e3440f96SFrançois Tigeot }
60e3440f96SFrançois Tigeot 
61*1ca9f5d2SFrançois Tigeot static inline void *
62*1ca9f5d2SFrançois Tigeot kmap_atomic_prot(struct page *pg, pgprot_t prot)
63*1ca9f5d2SFrançois Tigeot {
64*1ca9f5d2SFrançois Tigeot 	return kmap_atomic(pg);
65*1ca9f5d2SFrançois Tigeot }
66*1ca9f5d2SFrançois Tigeot 
67e3440f96SFrançois Tigeot static inline void kunmap_atomic(void *vaddr)
689a90aa3dSFrançois Tigeot {
699a90aa3dSFrançois Tigeot 	/* Nothing to do on systems with a direct memory map */
709a90aa3dSFrançois Tigeot }
719a90aa3dSFrançois Tigeot 
729a90aa3dSFrançois Tigeot #endif	/* _LINUX_HIGHMEM_H_ */
73