blob: 33b327379f0756e14eff3d9f0cd23a2f022eb112 [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/*
21 * Reserve the various regions of node 0
22 */
23void __init reserve_node_zero(pg_data_t *pgdat)
24{
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 King37efe642008-12-01 11:53:07 +000030 reserve_bootmem_node(pgdat, __pa(_data), _end - _data,
Bernhard Walle72a7fe32008-02-07 00:15:17 -080031 BOOTMEM_DEFAULT);
Russell Kingd111e8f2006-09-27 15:27:33 +010032#else
Russell King37efe642008-12-01 11:53:07 +000033 reserve_bootmem_node(pgdat, __pa(_stext), _end - _stext,
Bernhard Walle72a7fe32008-02-07 00:15:17 -080034 BOOTMEM_DEFAULT);
Russell Kingd111e8f2006-09-27 15:27:33 +010035#endif
36
37 /*
38 * Register the exception vector page.
39 * some architectures which the DRAM is the exception vector to trap,
40 * alloc_page breaks with error, although it is not NULL, but "0."
41 */
Bernhard Walle72a7fe32008-02-07 00:15:17 -080042 reserve_bootmem_node(pgdat, CONFIG_VECTORS_BASE, PAGE_SIZE,
43 BOOTMEM_DEFAULT);
Russell Kingd111e8f2006-09-27 15:27:33 +010044}
45
46/*
47 * paging_init() sets up the page tables, initialises the zone memory
48 * maps, and sets up the zero page, bad page and bad page tables.
49 */
Nicolas Pitre4b5f32c2008-10-06 13:24:40 -040050void __init paging_init(struct machine_desc *mdesc)
Russell Kingd111e8f2006-09-27 15:27:33 +010051{
Nicolas Pitre4b5f32c2008-10-06 13:24:40 -040052 bootmem_init();
Russell Kingd111e8f2006-09-27 15:27:33 +010053}
54
Russell King80878d62006-09-27 15:43:47 +010055/*
56 * We don't need to do anything here for nommu machines.
57 */
58void setup_mm_for_reboot(char mode)
59{
60}
61
Russell Kinge6b1b382006-06-24 10:46:23 +010062void flush_dcache_page(struct page *page)
63{
Russell King2c9b9c82009-11-26 12:56:21 +000064 __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
Russell Kinge6b1b382006-06-24 10:46:23 +010065}
Hyok S. Choi3e361222006-06-27 20:55:43 +010066EXPORT_SYMBOL(flush_dcache_page);
Russell Kinge6b1b382006-06-24 10:46:23 +010067
Catalin Marinasb5a07fa2010-05-06 15:15:28 +010068void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
69 unsigned long uaddr, void *dst, const void *src,
70 unsigned long len)
71{
72 memcpy(dst, src, len);
73 if (vma->vm_flags & VM_EXEC)
74 __cpuc_coherent_user_range(uaddr, uaddr + len);
75}
76
Russell King3603ab22007-05-05 20:59:27 +010077void __iomem *__arm_ioremap_pfn(unsigned long pfn, unsigned long offset,
78 size_t size, unsigned int mtype)
Russell King59244862006-06-22 15:05:36 +010079{
80 if (pfn >= (0x100000000ULL >> PAGE_SHIFT))
81 return NULL;
82 return (void __iomem *) (offset + (pfn << PAGE_SHIFT));
83}
Russell King3603ab22007-05-05 20:59:27 +010084EXPORT_SYMBOL(__arm_ioremap_pfn);
Russell King59244862006-06-22 15:05:36 +010085
Russell King31aa8fd2009-12-18 11:10:03 +000086void __iomem *__arm_ioremap_pfn_caller(unsigned long pfn, unsigned long offset,
87 size_t size, unsigned int mtype, void *caller)
88{
89 return __arm_ioremap_pfn(pfn, offset, size, mtype);
90}
91
Russell King3603ab22007-05-05 20:59:27 +010092void __iomem *__arm_ioremap(unsigned long phys_addr, size_t size,
93 unsigned int mtype)
Russell King59244862006-06-22 15:05:36 +010094{
95 return (void __iomem *)phys_addr;
96}
Russell King3603ab22007-05-05 20:59:27 +010097EXPORT_SYMBOL(__arm_ioremap);
Russell King59244862006-06-22 15:05:36 +010098
Catalin Marinasb1a9ceb2010-05-06 15:14:09 +010099void __iomem *__arm_ioremap_caller(unsigned long phys_addr, size_t size,
100 unsigned int mtype, void *caller)
Russell King31aa8fd2009-12-18 11:10:03 +0000101{
102 return __arm_ioremap(phys_addr, size, mtype);
103}
104
Russell King3ff15592006-11-30 13:53:54 +0000105void __iounmap(volatile void __iomem *addr)
Russell King59244862006-06-22 15:05:36 +0100106{
107}
108EXPORT_SYMBOL(__iounmap);