18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci#ifndef _PPC_BOOT_PAGE_H
38c2ecf20Sopenharmony_ci#define _PPC_BOOT_PAGE_H
48c2ecf20Sopenharmony_ci/*
58c2ecf20Sopenharmony_ci * Copyright (C) 2001 PPC64 Team, IBM Corp
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifdef __ASSEMBLY__
98c2ecf20Sopenharmony_ci#define ASM_CONST(x) x
108c2ecf20Sopenharmony_ci#else
118c2ecf20Sopenharmony_ci#define __ASM_CONST(x) x##UL
128c2ecf20Sopenharmony_ci#define ASM_CONST(x) __ASM_CONST(x)
138c2ecf20Sopenharmony_ci#endif
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/* PAGE_SHIFT determines the page size */
168c2ecf20Sopenharmony_ci#define PAGE_SHIFT	12
178c2ecf20Sopenharmony_ci#define PAGE_SIZE	(ASM_CONST(1) << PAGE_SHIFT)
188c2ecf20Sopenharmony_ci#define PAGE_MASK	(~(PAGE_SIZE-1))
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* align addr on a size boundary - adjust address up/down if needed */
218c2ecf20Sopenharmony_ci#define _ALIGN_UP(addr, size)	(((addr)+((size)-1))&(~((typeof(addr))(size)-1)))
228c2ecf20Sopenharmony_ci#define _ALIGN_DOWN(addr, size)	((addr)&(~((typeof(addr))(size)-1)))
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* align addr on a size boundary - adjust address up if needed */
258c2ecf20Sopenharmony_ci#define _ALIGN(addr,size)     _ALIGN_UP(addr,size)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/* to align the pointer to the (next) page boundary */
288c2ecf20Sopenharmony_ci#define PAGE_ALIGN(addr)	_ALIGN(addr, PAGE_SIZE)
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#endif				/* _PPC_BOOT_PAGE_H */
31