162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci#ifndef _PPC_BOOT_PAGE_H 362306a36Sopenharmony_ci#define _PPC_BOOT_PAGE_H 462306a36Sopenharmony_ci/* 562306a36Sopenharmony_ci * Copyright (C) 2001 PPC64 Team, IBM Corp 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifdef __ASSEMBLY__ 962306a36Sopenharmony_ci#define ASM_CONST(x) x 1062306a36Sopenharmony_ci#else 1162306a36Sopenharmony_ci#define __ASM_CONST(x) x##UL 1262306a36Sopenharmony_ci#define ASM_CONST(x) __ASM_CONST(x) 1362306a36Sopenharmony_ci#endif 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* PAGE_SHIFT determines the page size */ 1662306a36Sopenharmony_ci#define PAGE_SHIFT 12 1762306a36Sopenharmony_ci#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT) 1862306a36Sopenharmony_ci#define PAGE_MASK (~(PAGE_SIZE-1)) 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci/* align addr on a size boundary - adjust address up/down if needed */ 2162306a36Sopenharmony_ci#define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((typeof(addr))(size)-1))) 2262306a36Sopenharmony_ci#define _ALIGN_DOWN(addr, size) ((addr)&(~((typeof(addr))(size)-1))) 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci/* align addr on a size boundary - adjust address up if needed */ 2562306a36Sopenharmony_ci#define _ALIGN(addr,size) _ALIGN_UP(addr,size) 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci/* to align the pointer to the (next) page boundary */ 2862306a36Sopenharmony_ci#define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#endif /* _PPC_BOOT_PAGE_H */ 31