blob: ed58ddbbc5b30cd4afaa990c98be33101509ba20 [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 King3ff15592006-11-30 13:53:54 +00009#include <linux/bootmem.h>
Russell Kingfced80c2008-09-06 12:10:45 +010010#include <linux/io.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>
Russell King3ff15592006-11-30 13:53:54 +000016#include <asm/mach/arch.h>
Russell King59244862006-06-22 15:05:36 +010017
Russell Kingd111e8f2006-09-27 15:27:33 +010018#include "mm.h"
19
Russell Kingd111e8f2006-09-27 15:27:33 +010020/*
Russell Kingbe370302010-05-07 17:40:33 +010021 * Reserve the various regions
Russell Kingd111e8f2006-09-27 15:27:33 +010022 */
Russell Kingbe370302010-05-07 17:40:33 +010023void __init reserve_special_regions(void)
Russell Kingd111e8f2006-09-27 15:27:33 +010024{
25 /*
26 * Register the kernel text and data with bootmem.
27 * Note that this can only be in node 0.
28 */
29#ifdef CONFIG_XIP_KERNEL
Russell Kingbe370302010-05-07 17:40:33 +010030 reserve_bootmem(__pa(_data), _end - _data, BOOTMEM_DEFAULT);
Russell Kingd111e8f2006-09-27 15:27:33 +010031#else
Russell Kingbe370302010-05-07 17:40:33 +010032 reserve_bootmem(__pa(_stext), _end - _stext, BOOTMEM_DEFAULT);
Russell Kingd111e8f2006-09-27 15:27:33 +010033#endif
34
35 /*
36 * Register the exception vector page.
37 * some architectures which the DRAM is the exception vector to trap,
38 * alloc_page breaks with error, although it is not NULL, but "0."
39 */
Russell Kingbe370302010-05-07 17:40:33 +010040 reserve_bootmem(CONFIG_VECTORS_BASE, PAGE_SIZE, BOOTMEM_DEFAULT);
Russell Kingd111e8f2006-09-27 15:27:33 +010041}
42
43/*
44 * paging_init() sets up the page tables, initialises the zone memory
45 * maps, and sets up the zero page, bad page and bad page tables.
46 */
Nicolas Pitre4b5f32c2008-10-06 13:24:40 -040047void __init paging_init(struct machine_desc *mdesc)
Russell Kingd111e8f2006-09-27 15:27:33 +010048{
Russell King98c672c2010-05-22 18:18:57 +010049 bootmem_init(mdesc);
Russell Kingd111e8f2006-09-27 15:27:33 +010050}
51
Russell King80878d62006-09-27 15:43:47 +010052/*
53 * We don't need to do anything here for nommu machines.
54 */
55void setup_mm_for_reboot(char mode)
56{
57}
58
Russell Kinge6b1b382006-06-24 10:46:23 +010059void flush_dcache_page(struct page *page)
60{
Russell King2c9b9c82009-11-26 12:56:21 +000061 __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
Russell Kinge6b1b382006-06-24 10:46:23 +010062}
Hyok S. Choi3e361222006-06-27 20:55:43 +010063EXPORT_SYMBOL(flush_dcache_page);
Russell Kinge6b1b382006-06-24 10:46:23 +010064
Catalin Marinasb5a07fa2010-05-06 15:15:28 +010065void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
66 unsigned long uaddr, void *dst, const void *src,
67 unsigned long len)
68{
69 memcpy(dst, src, len);
70 if (vma->vm_flags & VM_EXEC)
71 __cpuc_coherent_user_range(uaddr, uaddr + len);
72}
73
Russell King3603ab22007-05-05 20:59:27 +010074void __iomem *__arm_ioremap_pfn(unsigned long pfn, unsigned long offset,
75 size_t size, unsigned int mtype)
Russell King59244862006-06-22 15:05:36 +010076{
77 if (pfn >= (0x100000000ULL >> PAGE_SHIFT))
78 return NULL;
79 return (void __iomem *) (offset + (pfn << PAGE_SHIFT));
80}
Russell King3603ab22007-05-05 20:59:27 +010081EXPORT_SYMBOL(__arm_ioremap_pfn);
Russell King59244862006-06-22 15:05:36 +010082
Russell King31aa8fd2009-12-18 11:10:03 +000083void __iomem *__arm_ioremap_pfn_caller(unsigned long pfn, unsigned long offset,
84 size_t size, unsigned int mtype, void *caller)
85{
86 return __arm_ioremap_pfn(pfn, offset, size, mtype);
87}
88
Russell King3603ab22007-05-05 20:59:27 +010089void __iomem *__arm_ioremap(unsigned long phys_addr, size_t size,
90 unsigned int mtype)
Russell King59244862006-06-22 15:05:36 +010091{
92 return (void __iomem *)phys_addr;
93}
Russell King3603ab22007-05-05 20:59:27 +010094EXPORT_SYMBOL(__arm_ioremap);
Russell King59244862006-06-22 15:05:36 +010095
Catalin Marinasb1a9ceb2010-05-06 15:14:09 +010096void __iomem *__arm_ioremap_caller(unsigned long phys_addr, size_t size,
97 unsigned int mtype, void *caller)
Russell King31aa8fd2009-12-18 11:10:03 +000098{
99 return __arm_ioremap(phys_addr, size, mtype);
100}
101
Russell King3ff15592006-11-30 13:53:54 +0000102void __iounmap(volatile void __iomem *addr)
Russell King59244862006-06-22 15:05:36 +0100103{
104}
105EXPORT_SYMBOL(__iounmap);