memory.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * linux/arch/unicore32/include/asm/memory.h
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Note: this file should not be included by non-asm/.h files
  13. */
  14. #ifndef __UNICORE_MEMORY_H__
  15. #define __UNICORE_MEMORY_H__
  16. #include <linux/compiler.h>
  17. #include <linux/const.h>
  18. #include <asm/sizes.h>
  19. #include <mach/memory.h>
  20. /*
  21. * Allow for constants defined here to be used from assembly code
  22. * by prepending the UL suffix only with actual C code compilation.
  23. */
  24. #define UL(x) _AC(x, UL)
  25. /*
  26. * PAGE_OFFSET - the virtual address of the start of the kernel image
  27. * TASK_SIZE - the maximum size of a user space task.
  28. * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
  29. */
  30. #define PAGE_OFFSET UL(0xC0000000)
  31. #define TASK_SIZE (PAGE_OFFSET - UL(0x41000000))
  32. #define TASK_UNMAPPED_BASE (PAGE_OFFSET / 3)
  33. /*
  34. * The module space lives between the addresses given by TASK_SIZE
  35. * and PAGE_OFFSET - it must be within 32MB of the kernel text.
  36. */
  37. #define MODULES_VADDR (PAGE_OFFSET - 16*1024*1024)
  38. #if TASK_SIZE > MODULES_VADDR
  39. #error Top of user space clashes with start of module space
  40. #endif
  41. #define MODULES_END (PAGE_OFFSET)
  42. /*
  43. * Allow 16MB-aligned ioremap pages
  44. */
  45. #define IOREMAP_MAX_ORDER 24
  46. /*
  47. * Physical vs virtual RAM address space conversion. These are
  48. * private definitions which should NOT be used outside memory.h
  49. * files. Use virt_to_phys/phys_to_virt/__pa/__va instead.
  50. */
  51. #ifndef __virt_to_phys
  52. #define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)
  53. #define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)
  54. #endif
  55. /*
  56. * Convert a page to/from a physical address
  57. */
  58. #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
  59. #define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))
  60. #ifndef __ASSEMBLY__
  61. #ifndef arch_adjust_zones
  62. #define arch_adjust_zones(size, holes) do { } while (0)
  63. #endif
  64. /*
  65. * PFNs are used to describe any physical page; this means
  66. * PFN 0 == physical address 0.
  67. *
  68. * This is the PFN of the first RAM page in the kernel
  69. * direct-mapped view. We assume this is the first page
  70. * of RAM in the mem_map as well.
  71. */
  72. #define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT)
  73. /*
  74. * Drivers should NOT use these either.
  75. */
  76. #define __pa(x) __virt_to_phys((unsigned long)(x))
  77. #define __va(x) ((void *)__phys_to_virt((unsigned long)(x)))
  78. #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
  79. /*
  80. * Conversion between a struct page and a physical address.
  81. *
  82. * page_to_pfn(page) convert a struct page * to a PFN number
  83. * pfn_to_page(pfn) convert a _valid_ PFN number to struct page *
  84. *
  85. * virt_to_page(k) convert a _valid_ virtual address to struct page *
  86. * virt_addr_valid(k) indicates whether a virtual address is valid
  87. */
  88. #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET
  89. #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
  90. #define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && \
  91. (unsigned long)(kaddr) < (unsigned long)high_memory)
  92. #endif
  93. #include <asm-generic/memory_model.h>
  94. #endif