Linux 6.13-rc4
[linux.git] / arch / openrisc / include / asm / page.h
blobc589e96035e15e690df9211843cb558737975b61
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * OpenRISC Linux
5 * Linux architectural port borrowing liberally from similar works of
6 * others. All original copyrights apply as per the original source
7 * declaration.
9 * OpenRISC implementation:
10 * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
11 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
12 * et al.
15 #ifndef __ASM_OPENRISC_PAGE_H
16 #define __ASM_OPENRISC_PAGE_H
18 #include <vdso/page.h>
20 #define PAGE_OFFSET 0xc0000000
21 #define KERNELBASE PAGE_OFFSET
23 /* This is not necessarily the right place for this, but it's needed by
24 * drivers/of/fdt.c
26 #include <asm/setup.h>
28 #ifndef __ASSEMBLY__
30 #define clear_page(page) memset((page), 0, PAGE_SIZE)
31 #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
33 #define clear_user_page(page, vaddr, pg) clear_page(page)
34 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
37 * These are used to make use of C type-checking..
39 typedef struct {
40 unsigned long pte;
41 } pte_t;
42 typedef struct {
43 unsigned long pgd;
44 } pgd_t;
45 typedef struct {
46 unsigned long pgprot;
47 } pgprot_t;
48 typedef struct page *pgtable_t;
50 #define pte_val(x) ((x).pte)
51 #define pgd_val(x) ((x).pgd)
52 #define pgprot_val(x) ((x).pgprot)
54 #define __pte(x) ((pte_t) { (x) })
55 #define __pgd(x) ((pgd_t) { (x) })
56 #define __pgprot(x) ((pgprot_t) { (x) })
58 #endif /* !__ASSEMBLY__ */
61 #ifndef __ASSEMBLY__
63 #define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
64 #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
66 static inline unsigned long virt_to_pfn(const void *kaddr)
68 return __pa(kaddr) >> PAGE_SHIFT;
71 #define virt_to_page(addr) \
72 (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
74 #define virt_addr_valid(kaddr) (pfn_valid(virt_to_pfn(kaddr)))
76 #endif /* __ASSEMBLY__ */
78 #include <asm-generic/memory_model.h>
79 #include <asm-generic/getorder.h>
81 #endif /* __ASM_OPENRISC_PAGE_H */