root/include/asm-i386/page.h

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

INCLUDED FROM


   1 #ifndef _I386_PAGE_H
   2 #define _I386_PAGE_H
   3 
   4 #define invalidate() \
   5 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3": : :"ax")
   6 
   7                         /* PAGE_SHIFT determines the page size */
   8 #define PAGE_SHIFT                      12
   9 #define PGDIR_SHIFT                     22
  10 #define PAGE_SIZE                       (1UL << PAGE_SHIFT)
  11 #define PGDIR_SIZE                      (1UL << PGDIR_SHIFT)
  12 
  13 #define PAGE_OFFSET     0
  14 #define MAP_NR(addr) ((addr) >> PAGE_SHIFT)
  15 #define MAP_PAGE_RESERVED (1<<15)
  16 
  17 typedef unsigned short mem_map_t;
  18 
  19 #define PAGE_PRESENT    0x001
  20 #define PAGE_RW         0x002
  21 #define PAGE_USER       0x004
  22 #define PAGE_PWT        0x008   /* 486 only - not used currently */
  23 #define PAGE_PCD        0x010   /* 486 only - not used currently */
  24 #define PAGE_ACCESSED   0x020
  25 #define PAGE_DIRTY      0x040
  26 #define PAGE_COW        0x200   /* implemented in software (one of the AVL bits) */
  27 
  28 #define PAGE_PRIVATE    (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
  29 #define PAGE_SHARED     (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
  30 #define PAGE_COPY       (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
  31 #define PAGE_READONLY   (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
  32 #define PAGE_EXECONLY   (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
  33 #define PAGE_TABLE      (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
  34 
  35 #define PAGE_CHG_MASK (PAGE_MASK | PAGE_ACCESSED | PAGE_DIRTY | PAGE_PWT | PAGE_PCD)
  36 
  37 #ifdef __KERNEL__
  38 
  39 /*
  40  * Define this if things work differently on a i386 and a i486:
  41  * it will (on a i486) warn about kernel memory accesses that are
  42  * done without a 'verify_area(VERIFY_WRITE,..)'
  43  */
  44 #undef CONFIG_TEST_VERIFY_AREA
  45 
  46 /* page table for 0-4MB for everybody */
  47 extern unsigned long pg0[1024];
  48 
  49 /*
  50  * BAD_PAGETABLE is used when we need a bogus page-table, while
  51  * BAD_PAGE is used for a bogus page.
  52  *
  53  * ZERO_PAGE is a global shared page that is always zero: used
  54  * for zero-mapped memory areas etc..
  55  */
  56 extern unsigned long __bad_page(void);
  57 extern unsigned long __bad_pagetable(void);
  58 extern unsigned long __zero_page(void);
  59 
  60 #define BAD_PAGETABLE __bad_pagetable()
  61 #define BAD_PAGE __bad_page()
  62 #define ZERO_PAGE __zero_page()
  63 
  64 /* number of bits that fit into a memory pointer */
  65 #define BITS_PER_PTR                    (8*sizeof(unsigned long))
  66 
  67 /* to mask away the intra-page address bits */
  68 #define PAGE_MASK                       (~(PAGE_SIZE-1))
  69 
  70 /* to mask away the intra-page address bits */
  71 #define PGDIR_MASK                      (~(PGDIR_SIZE-1))
  72 
  73 /* to align the pointer to the (next) page boundary */
  74 #define PAGE_ALIGN(addr)                (((addr)+PAGE_SIZE-1)&PAGE_MASK)
  75 
  76 /* to align the pointer to a pointer address */
  77 #define PTR_MASK                        (~(sizeof(void*)-1))
  78 
  79 /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
  80 /* 64-bit machines, beware!  SRB. */
  81 #define SIZEOF_PTR_LOG2                 2
  82 
  83 /* to find an entry in a page-table-directory */
  84 #define PAGE_DIR_OFFSET(tsk,address) \
  85 ((((unsigned long)(address)) >> 22) + (unsigned long *) (tsk)->tss.cr3)
  86 
  87 /* to find an entry in a page-table */
  88 #define PAGE_PTR(address)               \
  89 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
  90 
  91 /* the no. of pointers that fit on a page */
  92 #define PTRS_PER_PAGE                   (PAGE_SIZE/sizeof(void*))
  93 
  94 /* to set the page-dir */
  95 #define SET_PAGE_DIR(tsk,pgdir) \
  96 do { \
  97         (tsk)->tss.cr3 = (unsigned long) (pgdir); \
  98         if ((tsk) == current) \
  99                 __asm__ __volatile__("movl %0,%%cr3": :"a" ((tsk)->tss.cr3)); \
 100 } while (0)
 101 
 102 #endif /* __KERNEL__ */
 103 
 104 #endif /* _I386_PAGE_H */

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