highmem.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * highmem.h: virtual kernel memory mappings for high memory
  3.  *
  4.  * Used in CONFIG_HIGHMEM systems for memory pages which
  5.  * are not addressable by direct kernel virtual addresses.
  6.  *
  7.  * Copyright (C) 1999 Gerhard Wichert, Siemens AG
  8.  *       Gerhard.Wichert@pdb.siemens.de
  9.  *
  10.  *
  11.  * Redesigned the x86 32-bit VM architecture to deal with
  12.  * up to 16 Terabyte physical memory. With current x86 CPUs
  13.  * we now support up to 64 Gigabytes physical RAM.
  14.  *
  15.  * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
  16.  */
  17. #ifndef _ASM_HIGHMEM_H
  18. #define _ASM_HIGHMEM_H
  19. #ifdef __KERNEL__
  20. #include <linux/init.h>
  21. #include <linux/interrupt.h>
  22. #include <asm/kmap_types.h>
  23. #include <asm/pgtable.h>
  24. /* undef for production */
  25. #define HIGHMEM_DEBUG 1
  26. /* declarations for highmem.c */
  27. extern unsigned long highstart_pfn, highend_pfn;
  28. extern pte_t *kmap_pte;
  29. extern pgprot_t kmap_prot;
  30. extern pte_t *pkmap_page_table;
  31. /*
  32.  * Right now we initialize only a single pte table. It can be extended
  33.  * easily, subsequent pte tables have to be allocated in one physical
  34.  * chunk of RAM.
  35.  */
  36. #define PKMAP_BASE (0xfe000000UL)
  37. #define LAST_PKMAP 1024
  38. #define LAST_PKMAP_MASK (LAST_PKMAP-1)
  39. #define PKMAP_NR(virt)  ((virt-PKMAP_BASE) >> PAGE_SHIFT)
  40. #define PKMAP_ADDR(nr)  (PKMAP_BASE + ((nr) << PAGE_SHIFT))
  41. extern void * kmap_high(struct page *page);
  42. extern void kunmap_high(struct page *page);
  43. static inline void *kmap(struct page *page)
  44. {
  45. if (in_interrupt())
  46. out_of_line_bug();
  47. if (page < highmem_start_page)
  48. return page_address(page);
  49. return kmap_high(page);
  50. }
  51. static inline void kunmap(struct page *page)
  52. {
  53. if (in_interrupt())
  54. out_of_line_bug();
  55. if (page < highmem_start_page)
  56. return;
  57. kunmap_high(page);
  58. }
  59. /*
  60.  * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
  61.  * gives a more generic (and caching) interface. But kmap_atomic can
  62.  * be used in IRQ contexts, so in some (very limited) cases we need
  63.  * it.
  64.  */
  65. static inline void *kmap_atomic(struct page *page, enum km_type type)
  66. {
  67. enum fixed_addresses idx;
  68. unsigned long vaddr;
  69. if (page < highmem_start_page)
  70. return page_address(page);
  71. idx = type + KM_TYPE_NR*smp_processor_id();
  72. vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
  73. set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
  74. //local_flush_tlb_page(NULL, vaddr);
  75. local_flush_tlb_all();
  76. return (void*) vaddr;
  77. }
  78. static inline void kunmap_atomic(void *kvaddr, enum km_type type)
  79. {
  80. }
  81. #endif /* __KERNEL__ */
  82. #endif /* _ASM_HIGHMEM_H */