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

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