highmem.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * highmem.h: virtual kernel memory mappings for high memory
  3. *
  4. * PowerPC version, stolen from the i386 version.
  5. *
  6. * Used in CONFIG_HIGHMEM systems for memory pages which
  7. * are not addressable by direct kernel virtual addresses.
  8. *
  9. * Copyright (C) 1999 Gerhard Wichert, Siemens AG
  10. * Gerhard.Wichert@pdb.siemens.de
  11. *
  12. *
  13. * Redesigned the x86 32-bit VM architecture to deal with
  14. * up to 16 Terrabyte physical memory. With current x86 CPUs
  15. * we now support up to 64 Gigabytes physical RAM.
  16. *
  17. * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
  18. */
  19. #ifndef _ASM_HIGHMEM_H
  20. #define _ASM_HIGHMEM_H
  21. #ifdef __KERNEL__
  22. #include <linux/interrupt.h>
  23. #include <asm/kmap_types.h>
  24. #include <asm/tlbflush.h>
  25. #include <asm/page.h>
  26. #include <asm/fixmap.h>
  27. extern pte_t *kmap_pte;
  28. extern pgprot_t kmap_prot;
  29. extern pte_t *pkmap_page_table;
  30. /*
  31. * Right now we initialize only a single pte table. It can be extended
  32. * easily, subsequent pte tables have to be allocated in one physical
  33. * chunk of RAM.
  34. */
  35. /*
  36. * We use one full pte table with 4K pages. And with 16K/64K/256K pages pte
  37. * table covers enough memory (32MB/512MB/2GB resp.), so that both FIXMAP
  38. * and PKMAP can be placed in a single pte table. We use 512 pages for PKMAP
  39. * in case of 16K/64K/256K page sizes.
  40. */
  41. #ifdef CONFIG_PPC_4K_PAGES
  42. #define PKMAP_ORDER PTE_SHIFT
  43. #else
  44. #define PKMAP_ORDER 9
  45. #endif
  46. #define LAST_PKMAP (1 << PKMAP_ORDER)
  47. #ifndef CONFIG_PPC_4K_PAGES
  48. #define PKMAP_BASE (FIXADDR_START - PAGE_SIZE*(LAST_PKMAP + 1))
  49. #else
  50. #define PKMAP_BASE ((FIXADDR_START - PAGE_SIZE*(LAST_PKMAP + 1)) & PMD_MASK)
  51. #endif
  52. #define LAST_PKMAP_MASK (LAST_PKMAP-1)
  53. #define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT)
  54. #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
  55. extern void *kmap_high(struct page *page);
  56. extern void kunmap_high(struct page *page);
  57. extern void *kmap_atomic_prot(struct page *page, pgprot_t prot);
  58. extern void __kunmap_atomic(void *kvaddr);
  59. static inline void *kmap(struct page *page)
  60. {
  61. might_sleep();
  62. if (!PageHighMem(page))
  63. return page_address(page);
  64. return kmap_high(page);
  65. }
  66. static inline void kunmap(struct page *page)
  67. {
  68. BUG_ON(in_interrupt());
  69. if (!PageHighMem(page))
  70. return;
  71. kunmap_high(page);
  72. }
  73. static inline void *kmap_atomic(struct page *page)
  74. {
  75. return kmap_atomic_prot(page, kmap_prot);
  76. }
  77. #define flush_cache_kmaps() flush_cache_all()
  78. #endif /* __KERNEL__ */
  79. #endif /* _ASM_HIGHMEM_H */