home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / Include / Linux / mm.h < prev    next >
C/C++ Source or Header  |  2002-04-26  |  5KB  |  149 lines

  1. /* $Id: mm.h,v 1.2 2002/04/26 23:09:10 smilcke Exp $ */
  2.  
  3. #ifndef _LINUX_MM_H
  4. #define _LINUX_MM_H
  5.  
  6. #include <linux/sched.h>
  7. #include <linux/errno.h>
  8. #include <asm/page.h>
  9. #include <asm/atomic.h>
  10.  
  11. /*
  12.  * GFP bitmasks..
  13.  */
  14. /* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low four bits) */
  15. #define __GFP_DMA    0x01
  16. #define __GFP_HIGHMEM    0x02
  17.  
  18. /* Action modifiers - doesn't change the zoning */
  19. #define __GFP_WAIT    0x10    /* Can wait and reschedule? */
  20. #define __GFP_HIGH    0x20    /* Should access emergency pools? */
  21. #define __GFP_IO    0x40    /* Can start low memory physical IO? */
  22. #define __GFP_HIGHIO    0x80    /* Can start high mem physical IO? */
  23. #define __GFP_FS    0x100    /* Can call down to low-level FS? */
  24. #define __GFP_WAITBUF    0x200    /* Can we wait for buffers to complete? */
  25.  
  26. #define GFP_NOHIGHIO    (__GFP_HIGH | __GFP_WAIT | __GFP_IO)
  27. #define GFP_NOIO    (__GFP_HIGH | __GFP_WAIT)
  28. #define GFP_NOFS    (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_WAITBUF)
  29. #define GFP_ATOMIC    (__GFP_HIGH)
  30. #define GFP_USER    (             __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_WAITBUF | __GFP_FS)
  31. #define GFP_HIGHUSER    (             __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_WAITBUF | __GFP_FS | __GFP_HIGHMEM)
  32. #define GFP_KERNEL    (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_WAITBUF | __GFP_FS)
  33. #define GFP_NFS        (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_WAITBUF | __GFP_FS)
  34. #define GFP_KSWAPD    (             __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_WAITBUF | __GFP_FS)
  35.  
  36. /* Flag - indicates that the buffer will be suitable for DMA.  Ignored on some
  37.    platforms, used as appropriate on others */
  38.  
  39. #define GFP_DMA        __GFP_DMA
  40.  
  41. /* Flag - indicates that the buffer can be taken from high memory which is not
  42.    directly addressable by the kernel */
  43.  
  44. #define GFP_HIGHMEM    __GFP_HIGHMEM
  45.  
  46. /*
  47.  * This struct defines a memory VMM memory area. There is one of these
  48.  * per VM-area/task.  A VM area is any part of the process virtual memory
  49.  * space that has a special rule for the page-fault handlers (ie a shared
  50.  * library, the executable area etc).
  51.  */
  52. struct vm_area_struct {
  53.     struct mm_struct * vm_mm;    /* VM area parameters */
  54.     unsigned long vm_start;
  55.     unsigned long vm_end;
  56.  
  57.     /* linked list of VM areas per task, sorted by address */
  58.     struct vm_area_struct *vm_next;
  59.  
  60.     pgprot_t vm_page_prot;
  61.     unsigned short vm_flags;
  62.  
  63.     /* AVL tree of VM areas per task, sorted by address */
  64.     short vm_avl_height;
  65.     struct vm_area_struct * vm_avl_left;
  66.     struct vm_area_struct * vm_avl_right;
  67.  
  68.     /* For areas with inode, the list inode->i_mmap, for shm areas,
  69.      * the list of attaches, otherwise unused.
  70.      */
  71.     struct vm_area_struct *vm_next_share;
  72.     struct vm_area_struct **vm_pprev_share;
  73.  
  74.     struct vm_operations_struct * vm_ops;
  75.     unsigned long vm_pgoff;        /* offset in PAGE_SIZE units, *not* PAGE_CACHE_SIZE */
  76.     struct file * vm_file;
  77.     void * vm_private_data;        /* was vm_pte (shared mem) */
  78. };
  79.  
  80. /*
  81.  * vm_flags..
  82.  */
  83. #define VM_READ        0x0001    /* currently active flags */
  84. #define VM_WRITE    0x0002
  85. #define VM_EXEC        0x0004
  86. #define VM_SHARED    0x0008
  87.  
  88. #define VM_MAYREAD    0x0010    /* limits for mprotect() etc */
  89. #define VM_MAYWRITE    0x0020
  90. #define VM_MAYEXEC    0x0040
  91. #define VM_MAYSHARE    0x0080
  92.  
  93. #define VM_GROWSDOWN    0x0100    /* general info on the segment */
  94. #define VM_GROWSUP    0x0200
  95. #define VM_SHM        0x0400    /* shared memory area, don't swap out */
  96. #define VM_DENYWRITE    0x0800    /* ETXTBSY on write attempts.. */
  97.  
  98. #define VM_EXECUTABLE    0x1000
  99. #define VM_LOCKED    0x2000
  100. #define VM_IO           0x4000  /* Memory mapped I/O or similar */
  101.  
  102. #define VM_STACK_FLAGS    0x0177
  103.  
  104. /* Page flag bit values */
  105. #define PG_locked         0
  106. #define PG_error         1
  107. #define PG_referenced         2
  108. #define PG_uptodate         3
  109. #define PG_decr_after         5
  110. #define PG_DMA             7
  111. #define PG_slab             8
  112. #define PG_swap_cache         9
  113. #define PG_skip            10
  114. #define PG_swap_entry        11
  115. #define PG_highmem        12
  116.                 /* bits 21-30 unused */
  117. #define PG_reserved        31
  118.  
  119. typedef struct page {
  120.     unsigned long index;
  121.     atomic_t count;
  122.     unsigned long flags;    /* atomic flags, some possibly updated asynchronously */
  123.     unsigned long virt;     /* nonzero if kmapped */
  124. } mem_map_t;
  125.  
  126. extern mem_map_t * mem_map;
  127.  
  128. #define free_page(addr) free_pages((addr),0)
  129. #define virt_to_bus virt_to_phys
  130. #define __get_free_page(gfp_mask) __get_free_pages((gfp_mask),0)
  131. #define __get_dma_pages(gfp_mask, order) __get_free_pages((gfp_mask) | GFP_DMA,(order))
  132.  
  133. #if (defined(TARGET_OS2) && !defined(NOOS2LXAPI))
  134. extern int (*free_pages)(unsigned long addr,unsigned long order);
  135. extern struct page *(*alloc_pages)(int gfp_mask,unsigned long order);
  136. extern unsigned long (*virt_to_phys)(void *address);
  137. extern void *(*phys_to_virt)(unsigned long adress);
  138. extern int (*remap_page_range)(unsigned long from,unsigned long to,unsigned long size,pgprot_t prot);
  139. #else
  140. extern int free_pages(unsigned long addr, unsigned long order);
  141. extern unsigned long virt_to_phys(void * address);
  142. extern void * phys_to_virt(unsigned long address);
  143. extern void *__get_free_pages(int gfp_mask, unsigned long order);
  144. extern struct page * alloc_pages(int gfp_mask, unsigned long order);
  145. extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, pgprot_t prot);
  146. #endif
  147.  
  148. #endif
  149.