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

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef __LINUX_VMALLOC_H
  2. #define __LINUX_VMALLOC_H
  3. #include <linux/sched.h>
  4. #include <linux/mm.h>
  5. #include <linux/spinlock.h>
  6. #include <linux/highmem.h> /* several arch define VMALLOC_END via PKMAP_BASE */
  7. #include <asm/pgtable.h>
  8. /* bits in vm_struct->flags */
  9. #define VM_IOREMAP 0x00000001 /* ioremap() and friends */
  10. #define VM_ALLOC 0x00000002 /* vmalloc() */
  11. struct vm_struct {
  12. unsigned long flags;
  13. void * addr;
  14. unsigned long size;
  15. struct vm_struct * next;
  16. };
  17. extern struct vm_struct * get_vm_area (unsigned long size, unsigned long flags);
  18. extern void vfree(void * addr);
  19. extern void * __vmalloc (unsigned long size, int gfp_mask, pgprot_t prot);
  20. extern long vread(char *buf, char *addr, unsigned long count);
  21. extern void vmfree_area_pages(unsigned long address, unsigned long size);
  22. extern int vmalloc_area_pages(unsigned long address, unsigned long size,
  23.                               int gfp_mask, pgprot_t prot);
  24. /*
  25.  * Allocate any pages
  26.  */
  27.  
  28. static inline void * vmalloc (unsigned long size)
  29. {
  30. return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL);
  31. }
  32. /*
  33.  * Allocate ISA addressable pages for broke crap
  34.  */
  35. static inline void * vmalloc_dma (unsigned long size)
  36. {
  37. return __vmalloc(size, GFP_KERNEL|GFP_DMA, PAGE_KERNEL);
  38. }
  39. /*
  40.  * vmalloc 32bit PA addressable pages - eg for PCI 32bit devices
  41.  */
  42.  
  43. static inline void * vmalloc_32(unsigned long size)
  44. {
  45. return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL);
  46. }
  47. /*
  48.  * vmlist_lock is a read-write spinlock that protects vmlist
  49.  * Used in mm/vmalloc.c (get_vm_area() and vfree()) and fs/proc/kcore.c.
  50.  */
  51. extern rwlock_t vmlist_lock;
  52. extern struct vm_struct * vmlist;
  53. #endif