xref: /freebsd/sys/compat/linuxkpi/common/include/linux/pfn.h (revision 307f78f3ed90a4145eeb2c8cc79bc95b2666f57a)
18186b527SHans Petter Selasky /*-
28186b527SHans Petter Selasky  * Copyright (c) 2017 Mellanox Technologies, Ltd.
38186b527SHans Petter Selasky  * All rights reserved.
48186b527SHans Petter Selasky  *
58186b527SHans Petter Selasky  * Redistribution and use in source and binary forms, with or without
68186b527SHans Petter Selasky  * modification, are permitted provided that the following conditions
78186b527SHans Petter Selasky  * are met:
88186b527SHans Petter Selasky  * 1. Redistributions of source code must retain the above copyright
98186b527SHans Petter Selasky  *    notice unmodified, this list of conditions, and the following
108186b527SHans Petter Selasky  *    disclaimer.
118186b527SHans Petter Selasky  * 2. Redistributions in binary form must reproduce the above copyright
128186b527SHans Petter Selasky  *    notice, this list of conditions and the following disclaimer in the
138186b527SHans Petter Selasky  *    documentation and/or other materials provided with the distribution.
148186b527SHans Petter Selasky  *
158186b527SHans Petter Selasky  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
168186b527SHans Petter Selasky  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
178186b527SHans Petter Selasky  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
188186b527SHans Petter Selasky  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
198186b527SHans Petter Selasky  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
208186b527SHans Petter Selasky  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
218186b527SHans Petter Selasky  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
228186b527SHans Petter Selasky  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
238186b527SHans Petter Selasky  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
248186b527SHans Petter Selasky  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
258186b527SHans Petter Selasky  *
268186b527SHans Petter Selasky  * $FreeBSD$
278186b527SHans Petter Selasky  */
288186b527SHans Petter Selasky 
29*307f78f3SVladimir Kondratyev #ifndef _LINUXKPI_LINUX_PFN_H_
30*307f78f3SVladimir Kondratyev #define	_LINUXKPI_LINUX_PFN_H_
318186b527SHans Petter Selasky 
328186b527SHans Petter Selasky #include <linux/types.h>
338186b527SHans Petter Selasky 
348186b527SHans Petter Selasky typedef struct {
358186b527SHans Petter Selasky 	u64	val;
368186b527SHans Petter Selasky } pfn_t;
378186b527SHans Petter Selasky 
388186b527SHans Petter Selasky #define	PFN_ALIGN(x)	(((unsigned long)(x) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
398186b527SHans Petter Selasky #define	PFN_UP(x)	(((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
408186b527SHans Petter Selasky #define	PFN_DOWN(x)	((x) >> PAGE_SHIFT)
418186b527SHans Petter Selasky #define	PFN_PHYS(x)	((phys_addr_t)(x) << PAGE_SHIFT)
428186b527SHans Petter Selasky #define	PHYS_PFN(x)	((unsigned long)((x) >> PAGE_SHIFT))
438186b527SHans Petter Selasky 
44*307f78f3SVladimir Kondratyev #endif					/* _LINUXKPI_LINUX_PFN_H_ */
45