root/include/linux/mm.h

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

INCLUDED FROM


   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 extern unsigned long __bad_page(void);
  51 extern unsigned long __bad_pagetable(void);
  52 
  53 #define BAD_PAGETABLE __bad_pagetable()
  54 #define BAD_PAGE __bad_page()
  55 
  56 extern volatile short free_page_ptr; /* used by malloc and tcp/ip. */
  57 
  58 extern int nr_free_pages;
  59 extern unsigned long free_page_list;
  60 extern int nr_secondary_pages;
  61 extern unsigned long secondary_page_list;
  62 
  63 #define MAX_SECONDARY_PAGES 10
  64 
  65 extern void rw_swap_page(int rw, unsigned int nr, char * buf);
  66 
  67 #define read_swap_page(nr,buf) \
  68         rw_swap_page(READ,(nr),(buf))
  69 #define write_swap_page(nr,buf) \
  70         rw_swap_page(WRITE,(nr),(buf))
  71 
  72 /* mmap.c */
  73 
  74 /* memory.c */
  75         
  76 extern unsigned long get_free_page(int priority);
  77 extern unsigned long put_dirty_page(struct task_struct * tsk,unsigned long page,
  78         unsigned long address);
  79 extern void free_page(unsigned long addr);
  80 extern void free_page_tables(struct task_struct * tsk);
  81 extern void clear_page_tables(struct task_struct * tsk);
  82 extern int copy_page_tables(struct task_struct * new);
  83 extern int unmap_page_range(unsigned long from, unsigned long size);
  84 extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size,
  85          int permiss);
  86 extern void write_verify(unsigned long address);
  87 
  88 extern void do_wp_page(unsigned long error_code, unsigned long address,
  89         struct task_struct *tsk, unsigned long user_esp);
  90 extern void do_no_page(unsigned long error_code, unsigned long address,
  91         struct task_struct *tsk, unsigned long user_esp);
  92 
  93 extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem);
  94 extern void mem_init(unsigned long low_start_mem,
  95                      unsigned long start_mem, unsigned long end_mem);
  96 extern void show_mem(void);
  97 extern void do_page_fault(unsigned long *esp, unsigned long error_code);
  98 extern void oom(struct task_struct * task);
  99 extern void si_meminfo(struct sysinfo * val);
 100 
 101 /* swap.c */
 102 
 103 extern void swap_free(unsigned int page_nr);
 104 extern void swap_duplicate(unsigned int page_nr);
 105 extern void swap_in(unsigned long *table_ptr);
 106 extern void si_swapinfo(struct sysinfo * val);
 107 
 108 #define invalidate() \
 109 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3":::"ax")
 110 
 111 extern unsigned long high_memory;
 112 
 113 #define MAP_NR(addr) ((addr) >> PAGE_SHIFT)
 114 #define MAP_PAGE_RESERVED (1<<15)
 115 
 116 extern unsigned short * mem_map;
 117 
 118 #define PAGE_DIRTY      0x40
 119 #define PAGE_ACCESSED   0x20
 120 #define PAGE_USER       0x04
 121 #define PAGE_RW         0x02
 122 #define PAGE_PRESENT    0x01
 123 
 124 #define GFP_BUFFER      0x00
 125 #define GFP_ATOMIC      0x01
 126 #define GFP_USER        0x02
 127 #define GFP_KERNEL      0x03
 128 
 129 #endif

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