xref: /dragonfly/sys/dev/drm/include/asm/memory_model.h (revision e8537745)
1541aa16dSFrançois Tigeot /*
2*e8537745SFrançois Tigeot  * Copyright (c) 2016-2019 François Tigeot <ftigeot@wolfpond.org>
3541aa16dSFrançois Tigeot  * All rights reserved.
4541aa16dSFrançois Tigeot  *
5541aa16dSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6541aa16dSFrançois Tigeot  * modification, are permitted provided that the following conditions
7541aa16dSFrançois Tigeot  * are met:
8541aa16dSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9541aa16dSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10541aa16dSFrançois Tigeot  *    disclaimer.
11541aa16dSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12541aa16dSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13541aa16dSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14541aa16dSFrançois Tigeot  *
15541aa16dSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16541aa16dSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17541aa16dSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18541aa16dSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19541aa16dSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20541aa16dSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21541aa16dSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22541aa16dSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23541aa16dSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24541aa16dSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25541aa16dSFrançois Tigeot  */
26541aa16dSFrançois Tigeot 
27541aa16dSFrançois Tigeot #ifndef _ASM_MEMORY_MODEL_H_
28541aa16dSFrançois Tigeot #define _ASM_MEMORY_MODEL_H_
29541aa16dSFrançois Tigeot 
30f0bba3d1SFrançois Tigeot #include <vm/vm_object.h>
31f0bba3d1SFrançois Tigeot 
32f0bba3d1SFrançois Tigeot static inline unsigned long
page_to_pfn(struct page * page)33f0bba3d1SFrançois Tigeot page_to_pfn(struct page *page)
34f0bba3d1SFrançois Tigeot {
35f0bba3d1SFrançois Tigeot 	struct vm_page *p = (struct vm_page *)page;
36f0bba3d1SFrançois Tigeot 
37f0bba3d1SFrançois Tigeot 	return OFF_TO_IDX(VM_PAGE_TO_PHYS(p));
38f0bba3d1SFrançois Tigeot }
39f0bba3d1SFrançois Tigeot 
40*e8537745SFrançois Tigeot static inline struct page *
pfn_to_page(unsigned long pfn)41*e8537745SFrançois Tigeot pfn_to_page(unsigned long pfn)
42*e8537745SFrançois Tigeot {
43*e8537745SFrançois Tigeot 	return (struct page *)PHYS_TO_VM_PAGE(pfn << PAGE_SHIFT);
44*e8537745SFrançois Tigeot }
45541aa16dSFrançois Tigeot 
46541aa16dSFrançois Tigeot #endif	/* _ASM_MEMORY_MODEL_H_ */
47