root/include/linux/mm.h

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

INCLUDED FROM


DEFINITIONS

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

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