paging.h

Go to the documentation of this file.
00001 /* paging.h */
00002 
00003 #ifndef __SYSTEM
00004  #include "routix/system.h"
00005 #endif
00006 
00007 #ifndef __ROUTIX_PAGING
00008 #define __ROUTIX_PAGING
00009 
00010 #define DIR_SIZE        4096
00011 #define TABLA_SIZE      DIR_SIZE
00012 #define PAGINA_SIZE     4096
00013 #define TABLAS_POR_DIR  1024
00014 #define PAGINAS_POR_TABLA 1024
00015 
00016 #define POSICION_DIR_PAGINAS    ( KERNEL_FSTACK_TOP - KERNEL_STACK_SIZE - DIR_SIZE)
00017 #define POSICION_TABLA_1        ( POSICION_DIR_PAGINAS - DIR_SIZE)
00018 #define POSICION_TABLA_KCODE    ( POSICION_TABLA_1 - TABLA_SIZE )
00019 #define POSICION_TABLA_KDATA    ( POSICION_TABLA_KCODE - TABLA_SIZE )
00020 #define POSICION_TABLA_KSTACK   ( POSICION_TABLA_KDATA - TABLA_SIZE )
00021 
00022 //Tomamos 4Kb para la GDT 
00023 #define POSICION_TABLA_GDT      ( POSICION_TABLA_KSTACK - PAGINA_SIZE )
00024 
00025 
00027 #define PAGE_RW         0X02
00028 #define PAGE_PRES       0x01
00029 #define PAGE_SUPER      1<<2
00030 #define PAGE_USER       1<<2
00031 /*
00032 #define PAGE_USER       1<<2
00033 #define PAGE_SUPER      PAGE_USER
00034 */
00035 
00037 typedef dword pte_t;
00039 typedef dword pde_t;
00040 
00041 typedef struct pd_t {
00042         pde_t entry[1024];
00043 } pd_t;
00044 
00045 typedef struct pt_t {
00046         pte_t entry[1024];
00047 } pt_t;
00048 
00050 typedef struct page_index_t
00051 {
00052         word dir_index;
00053         word tabla_index;
00054 } page_index_t;
00055 
00056 
00058 page_index_t get_page_index (addr_t );
00059 
00060 
00061 /* Carga CR3 */
00062 #define load_cr3(x) __asm__ ("movl %0, %%cr3" : : "r" (x) )
00063 
00064 /* Desactiva/Activa la paginacion */
00065 #define page_off() __asm__ ("mov %cr0, %eax; and $0x7fffffff, %eax; mov %eax, %cr0")
00066 #define page_on()  __asm__ ("mov %cr0, %eax; or $0x80000000, %eax; mov %eax, %cr0")
00067 
00069 void *make_pdt (void);
00070 
00071 pde_t make_pde (addr_t direccion, word atributos);
00072 pte_t make_pte (addr_t direccion, word atributos);
00073 
00075 void *copy_page (void *dest, const void *src);
00076 
00078 void *convertir_direccion ( void *dir_logica, addr_t cr3 );
00079 
00080 int kmapmem ( addr_t fisica, addr_t logica, addr_t directorio, word atributo);
00081 int kunmapmem (addr_t logica, addr_t directorio);
00082 
00084 #define ALINEAR_4(dir)          (((long) dir) & 0xfffffffc)
00085 
00086 #define GET_OFFSET(dir)         (((long) dir) & 0xfff)
00087 
00088 #endif

Generated on Sun May 30 18:38:35 2004 for Routix OS by doxygen 1.3.6