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

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