00001 /* ndk - [ pager.h ] 00002 * 00003 * Functions for interacting with the x86 pager 00004 * 00005 * (c)2004 dcipher / neuraldk 00006 * www.neuraldk.org 00007 */ 00008 00017 #ifndef __ndk_pager_h__ 00018 #define __ndk_pager_h__ 00019 00020 #include "console.h" 00021 #include "errorCodes.h" 00022 #include "types.h" 00023 00024 #define CR0_PAGING_ENABLE (0x80000000) 00025 00026 // available for use in page directories and tables... 00027 #define PAGE_PRESENT (1) 00028 #define PAGE_READ_WRITE (2) 00029 #define PAGE_P3_ACCESS (4) 00030 #define PAGE_WRITE_THROUGH (8) 00031 #define PAGE_CACHE_DISABLE (16) 00032 #define PAGE_ACCESSED (32) 00033 00034 // page directories only 00035 #define PAGE_SIZE_4MB (128) 00036 00037 // page tables only 00038 #define PAGE_DIRTY (64) 00039 00040 // TODO: the following defines are from the old memory.c... clean them up! 00041 #define PAGE_SIZE (4096) 00042 00043 // start allocating at 2GB (linear) 00044 #define ALLOC_OFFSET (524288) 00045 00046 #define MULTI_PAGE_ENTRY (1) 00047 #define TOP_OF_DMA_STACK (4*1024*1024) 00048 00049 typedef struct 00050 { 00051 long pageTable[1024]; 00052 } __attribute__ ((packed)) PageDirectory; 00053 00054 typedef struct 00055 { 00056 long pageAddr[1024]; 00057 } __attribute__ ((packed)) PageTable; 00058 00059 typedef void *PhysicalAddress; 00060 typedef void *LinearAddress; 00061 00062 ErrorCode pagerInit(void); 00063 ErrorCode pagerGetPageSize(uint32 *page); 00064 ErrorCode pagerGetNewPhysical(PhysicalAddress * addr); 00065 ErrorCode pagerGetNewLinear(LinearAddress * addr); 00066 ErrorCode pagerMapPhysicalToLinear(PhysicalAddress phys, LinearAddress lin); 00067 ErrorCode pagerGetPhysical(LinearAddress lin, PhysicalAddress * addr); 00068 ErrorCode pagerGetLinear(PhysicalAddress phys, LinearAddress * addr); // possible/needed? 00069 00070 // remove/change 00071 //ErrorCode pagerMapPage(unsigned long physAddr); 00072 //void *pagerLinToPhys(void *linAddr); 00073 00074 #endif 00075