19a90aa3dSFrançois Tigeot /*
2*e706b1caSFrançois Tigeot * Copyright (c) 2014-2020 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 *
kmap_to_page(void * addr)416e31eb98SFrançois Tigeot kmap_to_page(void *addr)
426e31eb98SFrançois Tigeot {
43*e706b1caSFrançois Tigeot if (addr == NULL)
44*e706b1caSFrançois Tigeot return NULL;
45*e706b1caSFrançois Tigeot
46f0bba3d1SFrançois Tigeot return (struct page *)PHYS_TO_VM_PAGE(vtophys(addr));
476e31eb98SFrançois Tigeot }
486e31eb98SFrançois Tigeot
kmap(struct page * pg)49f0bba3d1SFrançois Tigeot static inline void *kmap(struct page *pg)
509a90aa3dSFrançois Tigeot {
51f0bba3d1SFrançois Tigeot return (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS( (struct vm_page *)pg ));
529a90aa3dSFrançois Tigeot }
539a90aa3dSFrançois Tigeot
kunmap(struct page * pg)54f0bba3d1SFrançois Tigeot static inline void kunmap(struct page *pg)
55e3440f96SFrançois Tigeot {
56e3440f96SFrançois Tigeot /* Nothing to do on systems with a direct memory map */
57e3440f96SFrançois Tigeot }
58e3440f96SFrançois Tigeot
kmap_atomic(struct page * pg)59f0bba3d1SFrançois Tigeot static inline void *kmap_atomic(struct page *pg)
60e3440f96SFrançois Tigeot {
61f0bba3d1SFrançois Tigeot return (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS( (struct vm_page *)pg ));
62e3440f96SFrançois Tigeot }
63e3440f96SFrançois Tigeot
641ca9f5d2SFrançois Tigeot static inline void *
kmap_atomic_prot(struct page * pg,pgprot_t prot)651ca9f5d2SFrançois Tigeot kmap_atomic_prot(struct page *pg, pgprot_t prot)
661ca9f5d2SFrançois Tigeot {
671ca9f5d2SFrançois Tigeot return kmap_atomic(pg);
681ca9f5d2SFrançois Tigeot }
691ca9f5d2SFrançois Tigeot
kunmap_atomic(void * vaddr)70e3440f96SFrançois Tigeot static inline void kunmap_atomic(void *vaddr)
719a90aa3dSFrançois Tigeot {
729a90aa3dSFrançois Tigeot /* Nothing to do on systems with a direct memory map */
739a90aa3dSFrançois Tigeot }
749a90aa3dSFrançois Tigeot
759a90aa3dSFrançois Tigeot #endif /* _LINUX_HIGHMEM_H_ */
76