root/include/linux/mm.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. __bad_page
  2. __bad_pagetable

   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         struct vm_area_struct * vm_next;        /* linked list */
  30         struct vm_area_struct * vm_share;       /* linked list */
  31         struct inode * vm_inode;
  32         unsigned long vm_offset;
  33         struct vm_operations_struct * vm_ops;
  34 };
  35 
  36 /*
  37  * These are the virtual MM functions - opening of an area, closing it (needed to
  38  * keep files on disk up-to-date etc), pointer to the functions called when a
  39  * no-page or a wp-page exception occurs, and the function which decides on sharing
  40  * of pages between different processes.
  41  */
  42 struct vm_operations_struct {
  43         void (*open)(struct vm_area_struct * area);
  44         void (*close)(struct vm_area_struct * area);
  45         void (*nopage)(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 * old, struct vm_area_struct * new, unsigned long address);
  48 };
  49 
  50 /*
  51  * BAD_PAGE is the page that is used for page faults when linux
  52  * is out-of-memory. Older versions of linux just did a
  53  * do_exit(), but using this instead means there is less risk
  54  * for a process dying in kernel mode, possibly leaving a inode
  55  * unused etc..
  56  *
  57  * BAD_PAGETABLE is the accompanying page-table: it is initialized
  58  * to point to BAD_PAGE entries.
  59  */
  60 extern unsigned long inline __bad_page(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  61 {
  62         extern char empty_bad_page[PAGE_SIZE];
  63 
  64         __asm__ __volatile__("cld ; rep ; stosl"
  65                 ::"a" (0),
  66                   "D" ((long) empty_bad_page),
  67                   "c" (1024)
  68                 :"di","cx");
  69         return (unsigned long) empty_bad_page;
  70 }
  71 #define BAD_PAGE __bad_page()
  72 
  73 extern unsigned long inline __bad_pagetable(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  74 {
  75         extern char empty_bad_page_table[PAGE_SIZE];
  76 
  77         __asm__ __volatile__("cld ; rep ; stosl"
  78                 ::"a" (7+BAD_PAGE),
  79                   "D" ((long) empty_bad_page_table),
  80                   "c" (1024)
  81                 :"di","cx");
  82         return (unsigned long) empty_bad_page_table;
  83 }
  84 #define BAD_PAGETABLE __bad_pagetable()
  85 
  86 extern volatile short free_page_ptr; /* used by malloc and tcp/ip. */
  87 
  88 extern int nr_free_pages;
  89 extern unsigned long free_page_list;
  90 extern int nr_secondary_pages;
  91 extern unsigned long secondary_page_list;
  92 
  93 #define MAX_SECONDARY_PAGES 10
  94 
  95 extern void rw_swap_page(int rw, unsigned int nr, char * buf);
  96 
  97 #define read_swap_page(nr,buf) \
  98         rw_swap_page(READ,(nr),(buf))
  99 #define write_swap_page(nr,buf) \
 100         rw_swap_page(WRITE,(nr),(buf))
 101 
 102 /* mmap.c */
 103 
 104 /* memory.c */
 105         
 106 extern unsigned long get_free_page(int priority);
 107 extern unsigned long put_dirty_page(struct task_struct * tsk,unsigned long page,
 108         unsigned long address);
 109 extern void free_page(unsigned long addr);
 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 * new);
 113 extern int unmap_page_range(unsigned long from, unsigned long size);
 114 extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size,
 115          int permiss);
 116 extern void write_verify(unsigned long address);
 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 do_page_fault(unsigned long *esp, unsigned long error_code);
 128 extern void oom(struct task_struct * task);
 129 
 130 /* swap.c */
 131 
 132 extern void swap_free(unsigned int page_nr);
 133 extern void swap_duplicate(unsigned int page_nr);
 134 extern void swap_in(unsigned long *table_ptr);
 135 
 136 #define invalidate() \
 137 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3":::"ax")
 138 
 139 extern unsigned long high_memory;
 140 
 141 #define MAP_NR(addr) ((addr) >> PAGE_SHIFT)
 142 #define MAP_PAGE_RESERVED (1<<15)
 143 
 144 extern unsigned short * mem_map;
 145 
 146 #define PAGE_DIRTY      0x40
 147 #define PAGE_ACCESSED   0x20
 148 #define PAGE_USER       0x04
 149 #define PAGE_RW         0x02
 150 #define PAGE_PRESENT    0x01
 151 
 152 #define GFP_BUFFER      0x00
 153 #define GFP_ATOMIC      0x01
 154 #define GFP_USER        0x02
 155 #define GFP_KERNEL      0x03
 156 
 157 #endif

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