fixmap.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * fixmap.h: compile-time virtual memory allocation
  4. *
  5. * Copyright (C) 1998 Ingo Molnar
  6. *
  7. * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
  8. */
  9. #ifndef _ASM_FIXMAP_H
  10. #define _ASM_FIXMAP_H
  11. #include <linux/kernel.h>
  12. #include <linux/threads.h>
  13. #include <asm/page.h>
  14. /*
  15. * Here we define all the compile-time 'special' virtual
  16. * addresses. The point is to have a constant address at
  17. * compile time, but to set the physical address only
  18. * in the boot process. We allocate these special addresses
  19. * from the end of P3 backwards.
  20. * Also this lets us do fail-safe vmalloc(), we
  21. * can guarantee that these special addresses and
  22. * vmalloc()-ed addresses never overlap.
  23. *
  24. * these 'compile-time allocated' memory buffers are
  25. * fixed-size 4k pages. (or larger if used with an increment
  26. * highger than 1) use fixmap_set(idx,phys) to associate
  27. * physical memory with fixmap indices.
  28. *
  29. * TLB entries of such buffers will not be flushed across
  30. * task switches.
  31. */
  32. /*
  33. * on UP currently we will have no trace of the fixmap mechanizm,
  34. * no page table allocations, etc. This might change in the
  35. * future, say framebuffers for the console driver(s) could be
  36. * fix-mapped?
  37. */
  38. enum fixed_addresses {
  39. /*
  40. * The FIX_CMAP entries are used by kmap_coherent() to get virtual
  41. * addresses which are of a known color, and so their values are
  42. * important. __fix_to_virt(FIX_CMAP_END - n) must give an address
  43. * which is the same color as a page (n<<PAGE_SHIFT).
  44. */
  45. #define FIX_N_COLOURS 8
  46. FIX_CMAP_BEGIN,
  47. FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * NR_CPUS) - 1,
  48. #ifdef CONFIG_IOREMAP_FIXED
  49. /*
  50. * FIX_IOREMAP entries are useful for mapping physical address
  51. * space before ioremap() is useable, e.g. really early in boot
  52. * before kmalloc() is working.
  53. */
  54. #define FIX_N_IOREMAPS 32
  55. FIX_IOREMAP_BEGIN,
  56. FIX_IOREMAP_END = FIX_IOREMAP_BEGIN + FIX_N_IOREMAPS - 1,
  57. #endif
  58. __end_of_fixed_addresses
  59. };
  60. extern void __set_fixmap(enum fixed_addresses idx,
  61. unsigned long phys, pgprot_t flags);
  62. extern void __clear_fixmap(enum fixed_addresses idx, pgprot_t flags);
  63. /*
  64. * used by vmalloc.c.
  65. *
  66. * Leave one empty page between vmalloc'ed areas and
  67. * the start of the fixmap, and leave one page empty
  68. * at the top of mem..
  69. */
  70. #define FIXADDR_TOP (P4SEG - PAGE_SIZE)
  71. #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
  72. #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
  73. #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE
  74. #include <asm-generic/fixmap.h>
  75. #endif