1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/unicore32/include/asm/memory.h
5 * Code specific to PKUnity SoC and UniCore ISA
7 * Copyright (C) 2001-2010 GUAN Xue-tao
9 * Note: this file should not be included by non-asm/.h files
11 #ifndef __UNICORE_MEMORY_H__
12 #define __UNICORE_MEMORY_H__
14 #include <linux/compiler.h>
15 #include <linux/const.h>
16 #include <linux/sizes.h>
17 #include <mach/memory.h>
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
24 #define PAGE_OFFSET UL(0xC0000000)
25 #define TASK_SIZE (PAGE_OFFSET - UL(0x41000000))
26 #define TASK_UNMAPPED_BASE (PAGE_OFFSET / 3)
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.
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
37 #define MODULES_END (PAGE_OFFSET)
40 * Allow 16MB-aligned ioremap pages
42 #define IOREMAP_MAX_ORDER 24
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.
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)
55 * Convert a page to/from a physical address
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)))
62 #ifndef arch_adjust_zones
63 #define arch_adjust_zones(size, holes) do { } while (0)
67 * PFNs are used to describe any physical page; this means
68 * PFN 0 == physical address 0.
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.
74 #define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT)
77 * Drivers should NOT use these either.
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)
84 * Conversion between a struct page and a physical address.
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 *
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
92 #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET
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)
100 #include <asm-generic/memory_model.h>