root/include/linux/mm.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. verify_area
  2. get_free_page

   1 #ifndef _LINUX_MM_H
   2 #define _LINUX_MM_H
   3 
   4 #include <linux/page.h>
   5 #include <linux/sched.h>
   6 #include <linux/errno.h>
   7 #include <linux/kernel.h>
   8 
   9 #define VERIFY_READ 0
  10 #define VERIFY_WRITE 1
  11 
  12 int __verify_write(unsigned long addr, unsigned long count);
  13 
  14 extern inline int verify_area(int type, void * addr, unsigned long size)
     /* [previous][next][first][last][top][bottom][index][help] */
  15 {
  16         if (TASK_SIZE <= (unsigned long) addr)
  17                 return -EFAULT;
  18         if (size > TASK_SIZE - (unsigned long) addr)
  19                 return -EFAULT;
  20         if (wp_works_ok || type == VERIFY_READ || !size)
  21                 return 0;
  22         return __verify_write((unsigned long) addr,size);
  23 }
  24 
  25 /*
  26  * Linux kernel virtual memory manager primitives.
  27  * The idea being to have a "virtual" mm in the same way
  28  * we have a virtual fs - giving a cleaner interface to the
  29  * mm details, and allowing different kinds of memory mappings
  30  * (from shared memory to executable loading to arbitrary
  31  * mmap() functions).
  32  */
  33 
  34 /*
  35  * This struct defines a memory VMM memory area. There is one of these
  36  * per VM-area/task.  A VM area is any part of the process virtual memory
  37  * space that has a special rule for the page-fault handlers (ie a shared
  38  * library, the executable area etc).
  39  */
  40 struct vm_area_struct {
  41         struct task_struct * vm_task;           /* VM area parameters */
  42         unsigned long vm_start;
  43         unsigned long vm_end;
  44         unsigned short vm_page_prot;
  45         struct vm_area_struct * vm_next;        /* linked list */
  46         struct vm_area_struct * vm_share;       /* linked list */
  47         struct inode * vm_inode;
  48         unsigned long vm_offset;
  49         struct vm_operations_struct * vm_ops;
  50 };
  51 
  52 /*
  53  * These are the virtual MM functions - opening of an area, closing it (needed to
  54  * keep files on disk up-to-date etc), pointer to the functions called when a
  55  * no-page or a wp-page exception occurs, and the function which decides on sharing
  56  * of pages between different processes.
  57  */
  58 struct vm_operations_struct {
  59         void (*open)(struct vm_area_struct * area);
  60         void (*close)(struct vm_area_struct * area);
  61         void (*nopage)(int error_code,
  62                        struct vm_area_struct * area, unsigned long address);
  63         void (*wppage)(struct vm_area_struct * area, unsigned long address);
  64         int (*share)(struct vm_area_struct * from, struct vm_area_struct * to, unsigned long address);
  65         int (*unmap)(struct vm_area_struct *area, unsigned long, size_t);
  66 };
  67 
  68 extern unsigned long __bad_page(void);
  69 extern unsigned long __bad_pagetable(void);
  70 extern unsigned long __zero_page(void);
  71 
  72 #define BAD_PAGETABLE __bad_pagetable()
  73 #define BAD_PAGE __bad_page()
  74 #define ZERO_PAGE __zero_page()
  75 
  76 extern volatile short free_page_ptr; /* used by malloc and tcp/ip. */
  77 
  78 extern int nr_swap_pages;
  79 extern int nr_free_pages;
  80 extern unsigned long free_page_list;
  81 extern int nr_secondary_pages;
  82 extern unsigned long secondary_page_list;
  83 
  84 #define MAX_SECONDARY_PAGES 10
  85 
  86 /*
  87  * This is timing-critical - most of the time in getting a new page
  88  * goes to clearing the page. If you want a page without the clearing
  89  * overhead, just use __get_free_page() directly..
  90  */
  91 extern unsigned long __get_free_page(int priority);
  92 extern inline unsigned long get_free_page(int priority)
     /* [previous][next][first][last][top][bottom][index][help] */
  93 {
  94         unsigned long page;
  95 
  96         page = __get_free_page(priority);
  97         if (page)
  98                 __asm__ __volatile__("rep ; stosl"
  99                         : /* no outputs */ \
 100                         :"a" (0),"c" (1024),"D" (page)
 101                         :"di","cx");
 102         return page;
 103 }
 104 
 105 /* memory.c */
 106 
 107 extern void free_page(unsigned long addr);
 108 extern unsigned long put_dirty_page(struct task_struct * tsk,unsigned long page,
 109         unsigned long address);
 110 extern void free_page_tables(struct task_struct * tsk);
 111 extern void clear_page_tables(struct task_struct * tsk);
 112 extern int copy_page_tables(struct task_struct * to);
 113 extern int clone_page_tables(struct task_struct * to);
 114 extern int unmap_page_range(unsigned long from, unsigned long size);
 115 extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, int mask);
 116 extern int zeromap_page_range(unsigned long from, unsigned long size, int mask);
 117 
 118 extern void do_wp_page(unsigned long error_code, unsigned long address,
 119         struct task_struct *tsk, unsigned long user_esp);
 120 extern void do_no_page(unsigned long error_code, unsigned long address,
 121         struct task_struct *tsk, unsigned long user_esp);
 122 
 123 extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem);
 124 extern void mem_init(unsigned long low_start_mem,
 125                      unsigned long start_mem, unsigned long end_mem);
 126 extern void show_mem(void);
 127 extern void oom(struct task_struct * task);
 128 extern void si_meminfo(struct sysinfo * val);
 129 
 130 /* vmalloc.c */
 131 
 132 extern void * vmalloc(unsigned long size);
 133 extern void vfree(void * addr);
 134 extern int vread(char *buf, char *addr, int count);
 135 
 136 /* swap.c */
 137 
 138 extern void swap_free(unsigned long page_nr);
 139 extern unsigned long swap_duplicate(unsigned long page_nr);
 140 extern void swap_in(unsigned long *table_ptr);
 141 extern void si_swapinfo(struct sysinfo * val);
 142 extern void rw_swap_page(int rw, unsigned long nr, char * buf);
 143 
 144 /* mmap.c */
 145 extern int do_mmap(struct file * file, unsigned long addr, unsigned long len,
 146         unsigned long prot, unsigned long flags, unsigned long off);
 147 typedef int (*map_mergep_fnp)(const struct vm_area_struct *,
 148                               const struct vm_area_struct *, void *);
 149 extern void merge_segments(struct vm_area_struct *, map_mergep_fnp, void *);
 150 extern void insert_vm_struct(struct task_struct *, struct vm_area_struct *);
 151 extern int ignoff_mergep(const struct vm_area_struct *,
 152                          const struct vm_area_struct *, void *);
 153 extern int do_munmap(unsigned long, size_t);
 154 
 155 #define read_swap_page(nr,buf) \
 156         rw_swap_page(READ,(nr),(buf))
 157 #define write_swap_page(nr,buf) \
 158         rw_swap_page(WRITE,(nr),(buf))
 159 
 160 #define invalidate() \
 161 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3": : :"ax")
 162 
 163 extern unsigned long high_memory;
 164 
 165 #define MAP_NR(addr) ((addr) >> PAGE_SHIFT)
 166 #define MAP_PAGE_RESERVED (1<<15)
 167 
 168 extern unsigned short * mem_map;
 169 
 170 #define PAGE_PRESENT    0x001
 171 #define PAGE_RW         0x002
 172 #define PAGE_USER       0x004
 173 #define PAGE_PWT        0x008   /* 486 only - not used currently */
 174 #define PAGE_PCD        0x010   /* 486 only - not used currently */
 175 #define PAGE_ACCESSED   0x020
 176 #define PAGE_DIRTY      0x040
 177 #define PAGE_COW        0x200   /* implemented in software (one of the AVL bits) */
 178 
 179 #define PAGE_PRIVATE    (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
 180 #define PAGE_SHARED     (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
 181 #define PAGE_COPY       (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
 182 #define PAGE_READONLY   (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
 183 #define PAGE_TABLE      (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
 184 
 185 #define GFP_BUFFER      0x00
 186 #define GFP_ATOMIC      0x01
 187 #define GFP_USER        0x02
 188 #define GFP_KERNEL      0x03
 189 
 190 
 191 /* vm_ops not present page codes */
 192 #define SHM_SWP_TYPE 0x41        
 193 extern void shm_no_page (ulong *);
 194 
 195 #endif

/* [previous][next][first][last][top][bottom][index][help] */