blob: d51225f90ae2d5d3af909ec87d29910bea4f23d5 [file] [log] [blame]
Russell King59244862006-06-22 15:05:36 +01001/*
2 * linux/arch/arm/mm/nommu.c
3 *
4 * ARM uCLinux supporting functions.
5 */
6#include <linux/module.h>
Russell Kinge6b1b382006-06-24 10:46:23 +01007#include <linux/mm.h>
8#include <linux/pagemap.h>
Russell Kingfced80c2008-09-06 12:10:45 +01009#include <linux/io.h>
Russell King2778f622010-07-09 16:27:52 +010010#include <linux/memblock.h>
Russell King59244862006-06-22 15:05:36 +010011
Russell Kinge6b1b382006-06-24 10:46:23 +010012#include <asm/cacheflush.h>
Russell King37efe642008-12-01 11:53:07 +000013#include <asm/sections.h>
Russell King59244862006-06-22 15:05:36 +010014#include <asm/page.h>
Catalin Marinasb32f3af2009-07-24 12:35:03 +010015#include <asm/setup.h>
Will Deacon6b8e5c92012-04-12 17:16:01 +010016#include <asm/traps.h>
Russell King3ff15592006-11-30 13:53:54 +000017#include <asm/mach/arch.h>
Russell King59244862006-06-22 15:05:36 +010018
Russell Kingd111e8f2006-09-27 15:27:33 +010019#include "mm.h"
20
Russell King2778f622010-07-09 16:27:52 +010021void __init arm_mm_memblock_reserve(void)
Russell Kingd111e8f2006-09-27 15:27:33 +010022{
23 /*
Russell Kingd111e8f2006-09-27 15:27:33 +010024 * Register the exception vector page.
25 * some architectures which the DRAM is the exception vector to trap,
26 * alloc_page breaks with error, although it is not NULL, but "0."
27 */
Russell King2778f622010-07-09 16:27:52 +010028 memblock_reserve(CONFIG_VECTORS_BASE, PAGE_SIZE);
Russell Kingd111e8f2006-09-27 15:27:33 +010029}
30
Russell King0371d3f2011-07-05 19:58:29 +010031void __init sanity_check_meminfo(void)
32{
Nicolas Pitre55a81732011-09-18 22:40:00 -040033 phys_addr_t end = bank_phys_end(&meminfo.bank[meminfo.nr_banks - 1]);
34 high_memory = __va(end - 1) + 1;
Russell King0371d3f2011-07-05 19:58:29 +010035}
36
Russell Kingd111e8f2006-09-27 15:27:33 +010037/*
38 * paging_init() sets up the page tables, initialises the zone memory
39 * maps, and sets up the zero page, bad page and bad page tables.
40 */
Nicolas Pitre4b5f32c2008-10-06 13:24:40 -040041void __init paging_init(struct machine_desc *mdesc)
Russell Kingd111e8f2006-09-27 15:27:33 +010042{
Will Deacon6b8e5c92012-04-12 17:16:01 +010043 early_trap_init((void *)CONFIG_VECTORS_BASE);
Russell King8d717a52010-05-22 19:47:18 +010044 bootmem_init();
Russell Kingd111e8f2006-09-27 15:27:33 +010045}
46
Russell King80878d62006-09-27 15:43:47 +010047/*
48 * We don't need to do anything here for nommu machines.
49 */
Russell King5aafec12011-11-01 10:15:27 +000050void setup_mm_for_reboot(void)
Russell King80878d62006-09-27 15:43:47 +010051{
52}
53
Russell Kinge6b1b382006-06-24 10:46:23 +010054void flush_dcache_page(struct page *page)
55{
Russell King2c9b9c82009-11-26 12:56:21 +000056 __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
Russell Kinge6b1b382006-06-24 10:46:23 +010057}
Hyok S. Choi3e361222006-06-27 20:55:43 +010058EXPORT_SYMBOL(flush_dcache_page);
Russell Kinge6b1b382006-06-24 10:46:23 +010059
Catalin Marinasb5a07fa2010-05-06 15:15:28 +010060void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
61 unsigned long uaddr, void *dst, const void *src,
62 unsigned long len)
63{
64 memcpy(dst, src, len);
65 if (vma->vm_flags & VM_EXEC)
66 __cpuc_coherent_user_range(uaddr, uaddr + len);
67}
68
Russell King3603ab22007-05-05 20:59:27 +010069void __iomem *__arm_ioremap_pfn(unsigned long pfn, unsigned long offset,
70 size_t size, unsigned int mtype)
Russell King59244862006-06-22 15:05:36 +010071{
72 if (pfn >= (0x100000000ULL >> PAGE_SHIFT))
73 return NULL;
74 return (void __iomem *) (offset + (pfn << PAGE_SHIFT));
75}
Russell King3603ab22007-05-05 20:59:27 +010076EXPORT_SYMBOL(__arm_ioremap_pfn);
Russell King59244862006-06-22 15:05:36 +010077
Russell King31aa8fd2009-12-18 11:10:03 +000078void __iomem *__arm_ioremap_pfn_caller(unsigned long pfn, unsigned long offset,
79 size_t size, unsigned int mtype, void *caller)
80{
81 return __arm_ioremap_pfn(pfn, offset, size, mtype);
82}
83
Russell King3603ab22007-05-05 20:59:27 +010084void __iomem *__arm_ioremap(unsigned long phys_addr, size_t size,
85 unsigned int mtype)
Russell King59244862006-06-22 15:05:36 +010086{
87 return (void __iomem *)phys_addr;
88}
Russell King3603ab22007-05-05 20:59:27 +010089EXPORT_SYMBOL(__arm_ioremap);
Russell King59244862006-06-22 15:05:36 +010090
Rob Herring8a2b6252012-03-10 21:24:04 -060091void __iomem * (*arch_ioremap_caller)(unsigned long, size_t, unsigned int, void *);
92
Catalin Marinasb1a9ceb2010-05-06 15:14:09 +010093void __iomem *__arm_ioremap_caller(unsigned long phys_addr, size_t size,
94 unsigned int mtype, void *caller)
Russell King31aa8fd2009-12-18 11:10:03 +000095{
96 return __arm_ioremap(phys_addr, size, mtype);
97}
98
Rob Herring8a2b6252012-03-10 21:24:04 -060099void (*arch_iounmap)(volatile void __iomem *);
100
101void __arm_iounmap(volatile void __iomem *addr)
Russell King59244862006-06-22 15:05:36 +0100102{
103}
Rob Herring8a2b6252012-03-10 21:24:04 -0600104EXPORT_SYMBOL(__arm_iounmap);