Path: blob/master/arch/unicore32/include/asm/memory.h
10818 views
/*1* linux/arch/unicore32/include/asm/memory.h2*3* Code specific to PKUnity SoC and UniCore ISA4*5* Copyright (C) 2001-2010 GUAN Xue-tao6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License version 2 as9* published by the Free Software Foundation.10*11* Note: this file should not be included by non-asm/.h files12*/13#ifndef __UNICORE_MEMORY_H__14#define __UNICORE_MEMORY_H__1516#include <linux/compiler.h>17#include <linux/const.h>18#include <asm/sizes.h>19#include <mach/memory.h>2021/*22* Allow for constants defined here to be used from assembly code23* by prepending the UL suffix only with actual C code compilation.24*/25#define UL(x) _AC(x, UL)2627/*28* PAGE_OFFSET - the virtual address of the start of the kernel image29* TASK_SIZE - the maximum size of a user space task.30* TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area31*/32#define PAGE_OFFSET UL(0xC0000000)33#define TASK_SIZE (PAGE_OFFSET - UL(0x41000000))34#define TASK_UNMAPPED_BASE (PAGE_OFFSET / 3)3536/*37* The module space lives between the addresses given by TASK_SIZE38* and PAGE_OFFSET - it must be within 32MB of the kernel text.39*/40#define MODULES_VADDR (PAGE_OFFSET - 16*1024*1024)41#if TASK_SIZE > MODULES_VADDR42#error Top of user space clashes with start of module space43#endif4445#define MODULES_END (PAGE_OFFSET)4647/*48* Allow 16MB-aligned ioremap pages49*/50#define IOREMAP_MAX_ORDER 245152/*53* Physical vs virtual RAM address space conversion. These are54* private definitions which should NOT be used outside memory.h55* files. Use virt_to_phys/phys_to_virt/__pa/__va instead.56*/57#ifndef __virt_to_phys58#define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)59#define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)60#endif6162/*63* Convert a physical address to a Page Frame Number and back64*/65#define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT)66#define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)6768/*69* Convert a page to/from a physical address70*/71#define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))72#define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))7374#ifndef __ASSEMBLY__7576#ifndef arch_adjust_zones77#define arch_adjust_zones(size, holes) do { } while (0)78#endif7980/*81* PFNs are used to describe any physical page; this means82* PFN 0 == physical address 0.83*84* This is the PFN of the first RAM page in the kernel85* direct-mapped view. We assume this is the first page86* of RAM in the mem_map as well.87*/88#define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT)8990/*91* Drivers should NOT use these either.92*/93#define __pa(x) __virt_to_phys((unsigned long)(x))94#define __va(x) ((void *)__phys_to_virt((unsigned long)(x)))95#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)9697/*98* Conversion between a struct page and a physical address.99*100* Note: when converting an unknown physical address to a101* struct page, the resulting pointer must be validated102* using VALID_PAGE(). It must return an invalid struct page103* for any physical address not corresponding to a system104* RAM address.105*106* page_to_pfn(page) convert a struct page * to a PFN number107* pfn_to_page(pfn) convert a _valid_ PFN number to struct page *108*109* virt_to_page(k) convert a _valid_ virtual address to struct page *110* virt_addr_valid(k) indicates whether a virtual address is valid111*/112#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET113114#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)115#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && \116(unsigned long)(kaddr) < (unsigned long)high_memory)117118#endif119120#include <asm-generic/memory_model.h>121122#endif123124125