1/* 2 * linux/include/asm-arm/arch-sa1100/memory.h 3 * 4 * Copyright (C) 1999-2000 Nicolas Pitre <nico@cam.org> 5 */ 6 7#ifndef __ASM_ARCH_MEMORY_H 8#define __ASM_ARCH_MEMORY_H 9 10#include <linux/config.h> 11 12/* 13 * Task size: 3GB 14 */ 15#define TASK_SIZE (0xc0000000UL) 16#define TASK_SIZE_26 (0x04000000UL) 17 18/* 19 * This decides where the kernel will search for a free chunk of vm 20 * space during mmap's. 21 */ 22#define TASK_UNMAPPED_BASE (TASK_SIZE / 3) 23 24/* 25 * Page offset: 3GB 26 */ 27#define PAGE_OFFSET (0xc0000000UL) 28 29/* 30 * Physical DRAM offset is 0xc0000000 on the SA1100 31 */ 32#define PHYS_OFFSET (0xc0000000UL) 33 34/* 35 * We take advantage of the fact that physical and virtual address can be the 36 * same. The NUMA code is handling the large holes that might exist between 37 * all memory banks. 38 */ 39#define __virt_to_phys__is_a_macro 40#define __phys_to_virt__is_a_macro 41#define __virt_to_phys(x) (x) 42#define __phys_to_virt(x) (x) 43 44/* 45 * Virtual view <-> DMA view memory address translations 46 * virt_to_bus: Used to translate the virtual address to an 47 * address suitable to be passed to set_dma_addr 48 * bus_to_virt: Used to convert an address for DMA operations 49 * to an address that the kernel can use. 50 * 51 * On the SA1100, bus addresses are equivalent to physical addresses. 52 */ 53#define __virt_to_bus__is_a_macro 54#define __bus_to_virt__is_a_macro 55#define __virt_to_bus(x) __virt_to_phys(x) 56#define __bus_to_virt(x) __phys_to_virt(x) 57 58#ifdef CONFIG_DISCONTIGMEM 59/* 60 * Because of the wide memory address space between physical RAM banks on the 61 * SA1100, it's much convenient to use Linux's NUMA support to implement our 62 * memory map representation. Assuming all memory nodes have equal access 63 * characteristics, we then have generic discontigous memory support. 64 * 65 * Of course, all this isn't mandatory for SA1100 implementations with only 66 * one used memory bank. For those, simply undefine CONFIG_DISCONTIGMEM. 67 * 68 * The nodes are matched with the physical memory bank addresses which are 69 * incidentally the same as virtual addresses. 70 * 71 * node 0: 0xc0000000 - 0xc7ffffff 72 * node 1: 0xc8000000 - 0xcfffffff 73 * node 2: 0xd0000000 - 0xd7ffffff 74 * node 3: 0xd8000000 - 0xdfffffff 75 */ 76 77#define NR_NODES 4 78 79/* 80 * Given a kernel address, find the home node of the underlying memory. 81 */ 82#define KVADDR_TO_NID(addr) \ 83 (((unsigned long)(addr) - 0xc0000000) >> 27) 84 85/* 86 * Given a physical address, convert it to a node id. 87 */ 88#define PHYS_TO_NID(addr) KVADDR_TO_NID(__phys_to_virt(addr)) 89 90/* 91 * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory 92 * and returns the mem_map of that node. 93 */ 94#define ADDR_TO_MAPBASE(kaddr) \ 95 NODE_MEM_MAP(KVADDR_TO_NID((unsigned long)(kaddr))) 96 97/* 98 * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory 99 * and returns the index corresponding to the appropriate page in the 100 * node's mem_map. 101 */ 102#define LOCAL_MAP_NR(kvaddr) \ 103 (((unsigned long)(kvaddr) & 0x07ffffff) >> PAGE_SHIFT) 104 105/* 106 * Given a kaddr, virt_to_page returns a pointer to the corresponding 107 * mem_map entry. 108 */ 109#define virt_to_page(kaddr) \ 110 (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr)) 111 112/* 113 * VALID_PAGE returns a non-zero value if given page pointer is valid. 114 * This assumes all node's mem_maps are stored within the node they refer to. 115 */ 116#define VALID_PAGE(page) \ 117({ unsigned int node = KVADDR_TO_NID(page); \ 118 ( (node < NR_NODES) && \ 119 ((unsigned)((page) - NODE_MEM_MAP(node)) < NODE_DATA(node)->node_size) ); \ 120}) 121 122#else 123 124#define PHYS_TO_NID(addr) (0) 125 126#endif 127 128#endif 129