Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * linux/arch/unicore32/include/asm/memory.h
4 *
5 * Code specific to PKUnity SoC and UniCore ISA
6 *
7 * Copyright (C) 2001-2010 GUAN Xue-tao
8 *
9 * Note: this file should not be included by non-asm/.h files
10 */
11#ifndef __UNICORE_MEMORY_H__
12#define __UNICORE_MEMORY_H__
13
14#include <linux/compiler.h>
15#include <linux/const.h>
16#include <linux/sizes.h>
17#include <mach/memory.h>
18
19/*
20 * PAGE_OFFSET - the virtual address of the start of the kernel image
21 * TASK_SIZE - the maximum size of a user space task.
22 * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
23 */
24#define PAGE_OFFSET UL(0xC0000000)
25#define TASK_SIZE (PAGE_OFFSET - UL(0x41000000))
26#define TASK_UNMAPPED_BASE (PAGE_OFFSET / 3)
27
28/*
29 * The module space lives between the addresses given by TASK_SIZE
30 * and PAGE_OFFSET - it must be within 32MB of the kernel text.
31 */
32#define MODULES_VADDR (PAGE_OFFSET - 16*1024*1024)
33#if TASK_SIZE > MODULES_VADDR
34#error Top of user space clashes with start of module space
35#endif
36
37#define MODULES_END (PAGE_OFFSET)
38
39/*
40 * Allow 16MB-aligned ioremap pages
41 */
42#define IOREMAP_MAX_ORDER 24
43
44/*
45 * Physical vs virtual RAM address space conversion. These are
46 * private definitions which should NOT be used outside memory.h
47 * files. Use virt_to_phys/phys_to_virt/__pa/__va instead.
48 */
49#ifndef __virt_to_phys
50#define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)
51#define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)
52#endif
53
54/*
55 * Convert a page to/from a physical address
56 */
57#define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
58#define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))
59
60#ifndef __ASSEMBLY__
61
62#ifndef arch_adjust_zones
63#define arch_adjust_zones(size, holes) do { } while (0)
64#endif
65
66/*
67 * PFNs are used to describe any physical page; this means
68 * PFN 0 == physical address 0.
69 *
70 * This is the PFN of the first RAM page in the kernel
71 * direct-mapped view. We assume this is the first page
72 * of RAM in the mem_map as well.
73 */
74#define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT)
75
76/*
77 * Drivers should NOT use these either.
78 */
79#define __pa(x) __virt_to_phys((unsigned long)(x))
80#define __va(x) ((void *)__phys_to_virt((unsigned long)(x)))
81#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
82
83/*
84 * Conversion between a struct page and a physical address.
85 *
86 * page_to_pfn(page) convert a struct page * to a PFN number
87 * pfn_to_page(pfn) convert a _valid_ PFN number to struct page *
88 *
89 * virt_to_page(k) convert a _valid_ virtual address to struct page *
90 * virt_addr_valid(k) indicates whether a virtual address is valid
91 */
92#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET
93
94#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
95#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && \
96 (unsigned long)(kaddr) < (unsigned long)high_memory)
97
98#endif
99
100#include <asm-generic/memory_model.h>
101
102#endif