uncached.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/init.h>
  3. #include <linux/module.h>
  4. #include <asm/sizes.h>
  5. #include <asm/page.h>
  6. #include <asm/addrspace.h>
  7. /*
  8. * This is the offset of the uncached section from its cached alias.
  9. *
  10. * Legacy platforms handle trivial transitions between cached and
  11. * uncached segments by making use of the 1:1 mapping relationship in
  12. * 512MB lowmem, others via a special uncached mapping.
  13. *
  14. * Default value only valid in 29 bit mode, in 32bit mode this will be
  15. * updated by the early PMB initialization code.
  16. */
  17. unsigned long cached_to_uncached = SZ_512M;
  18. unsigned long uncached_size = SZ_512M;
  19. unsigned long uncached_start, uncached_end;
  20. EXPORT_SYMBOL(uncached_start);
  21. EXPORT_SYMBOL(uncached_end);
  22. int virt_addr_uncached(unsigned long kaddr)
  23. {
  24. return (kaddr >= uncached_start) && (kaddr < uncached_end);
  25. }
  26. EXPORT_SYMBOL(virt_addr_uncached);
  27. void __init uncached_init(void)
  28. {
  29. #if defined(CONFIG_29BIT) || !defined(CONFIG_MMU)
  30. uncached_start = P2SEG;
  31. #else
  32. uncached_start = memory_end;
  33. #endif
  34. uncached_end = uncached_start + uncached_size;
  35. }
  36. void __init uncached_resize(unsigned long size)
  37. {
  38. uncached_size = size;
  39. uncached_end = uncached_start + uncached_size;
  40. }