memory.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * linux/arch/m68knommu/mm/memory.c
  3. *
  4. * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
  5. * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
  6. *
  7. * Based on:
  8. *
  9. * linux/arch/m68k/mm/memory.c
  10. *
  11. * Copyright (C) 1995 Hamish Macdonald
  12. */
  13. #include <linux/config.h>
  14. #include <linux/mm.h>
  15. #include <linux/kernel.h>
  16. #include <linux/string.h>
  17. #include <linux/types.h>
  18. #include <linux/slab.h>
  19. #include <asm/setup.h>
  20. #include <asm/segment.h>
  21. #include <asm/page.h>
  22. #include <asm/pgtable.h>
  23. #include <asm/system.h>
  24. #include <asm/traps.h>
  25. #include <asm/io.h>
  26. /*
  27. * cache_clear() semantics: Clear any cache entries for the area in question,
  28. * without writing back dirty entries first. This is useful if the data will
  29. * be overwritten anyway, e.g. by DMA to memory. The range is defined by a
  30. * _physical_ address.
  31. */
  32. void cache_clear (unsigned long paddr, int len)
  33. {
  34. }
  35. /*
  36. * Define cache invalidate functions. The ColdFire 5407 is really
  37. * the only processor that needs to do some work here. Anything
  38. * that has separate data and instruction caches will be a problem.
  39. */
  40. #ifdef CONFIG_M5407
  41. static __inline__ void cache_invalidate_lines(unsigned long paddr, int len)
  42. {
  43. unsigned long sset, eset;
  44. sset = (paddr & 0x00000ff0);
  45. eset = ((paddr + len) & 0x0000ff0) + 0x10;
  46. __asm__ __volatile__ (
  47. "nop\n\t"
  48. "clrl %%d0\n\t"
  49. "1:\n\t"
  50. "movel %0,%%a0\n\t"
  51. "addl %%d0,%%a0\n\t"
  52. "2:\n\t"
  53. ".word 0xf4e8\n\t"
  54. "addl #0x10,%%a0\n\t"
  55. "cmpl %1,%%a0\n\t"
  56. "blt 2b\n\t"
  57. "addql #1,%%d0\n\t"
  58. "cmpil #4,%%d0\n\t"
  59. "bne 1b"
  60. : : "a" (sset), "a" (eset) : "d0", "a0" );
  61. }
  62. #else
  63. #define cache_invalidate_lines(a,b)
  64. #endif
  65. /*
  66. * cache_push() semantics: Write back any dirty cache data in the given area,
  67. * and invalidate the range in the instruction cache. It needs not (but may)
  68. * invalidate those entries also in the data cache. The range is defined by a
  69. * _physical_ address.
  70. */
  71. void cache_push (unsigned long paddr, int len)
  72. {
  73. cache_invalidate_lines(paddr, len);
  74. }
  75. /*
  76. * cache_push_v() semantics: Write back any dirty cache data in the given
  77. * area, and invalidate those entries at least in the instruction cache. This
  78. * is intended to be used after data has been written that can be executed as
  79. * code later. The range is defined by a _user_mode_ _virtual_ address (or,
  80. * more exactly, the space is defined by the %sfc/%dfc register.)
  81. */
  82. void cache_push_v (unsigned long vaddr, int len)
  83. {
  84. cache_invalidate_lines(vaddr, len);
  85. }
  86. /* Map some physical address range into the kernel address space. The
  87. * code is copied and adapted from map_chunk().
  88. */
  89. unsigned long kernel_map(unsigned long paddr, unsigned long size,
  90. int nocacheflag, unsigned long *memavailp )
  91. {
  92. return paddr;
  93. }
  94. int is_in_rom(unsigned long addr)
  95. {
  96. extern unsigned long _ramstart, _ramend;
  97. /*
  98. * What we are really trying to do is determine if addr is
  99. * in an allocated kernel memory region. If not then assume
  100. * we cannot free it or otherwise de-allocate it. Ideally
  101. * we could restrict this to really being in a ROM or flash,
  102. * but that would need to be done on a board by board basis,
  103. * not globally.
  104. */
  105. if ((addr < _ramstart) || (addr >= _ramend))
  106. return(1);
  107. /* Default case, not in ROM */
  108. return(0);
  109. }