00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 #ifndef _PAGING_H
00031 #define _PAGING_H
00032 
00033 #include <ubixos/types.h>
00034 #include <sys/sysproto.h>
00035 #include <sys/thread.h>
00036 
00037 #define VM_THRD           0
00038 #define VM_TASK           1
00039 
00040 #define pageLength        0x00000400
00041 #define pageSize          4096
00042 #define pageEntries       (pageSize/4)
00043 #define tablesBaseAddress   0xBFC00000
00044 #define parentPageDirAddr   0x100000
00045 
00046 #define PAGE_COW            0x00000200
00047 #define PAGE_STACK          0x00000400
00048 #define PAGE_WIRED          0x00000600
00049 #define PAGE_PRESENT        0x00000001
00050 #define PAGE_WRITE          0x00000002
00051 #define PAGE_USER           0x00000004
00052 #define PAGE_DEFAULT        (PAGE_PRESENT|PAGE_WRITE|PAGE_USER)
00053 #define KERNEL_PAGE_DEFAULT (PAGE_PRESENT|PAGE_WRITE)
00054 
00055 #define PAGE_SHIFT      12              
00056 #define PAGE_SIZE       (1<<PAGE_SHIFT) 
00057 #define PAGE_MASK       (PAGE_SIZE-1)
00058 
00059 #define trunc_page(x)           ((x) & ~PAGE_MASK)
00060 #define round_page(x)   (((x) + PAGE_MASK) & ~PAGE_MASK)
00061 #define ctob(x)                 ((x)<<PAGE_SHIFT)
00062 #define btoc(x)                 (((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT)
00063 
00064 
00065 int vmmClearVirtualPage(uInt32 pageAddr);
00066 
00067 void vmmUnmapPage(uInt32,int);
00068 void vmmUnmapPages(void *,uInt32);
00069 void *vmmMapFromTask(pidType,void *,uInt32);
00070 void *vmmCopyVirtualSpace(pidType);
00071 void *vmmGetFreePage(pidType);
00072 void *vmmGetFreeKernelPage(pidType pid,uInt16 count);
00073 void *vmmCreateVirtualSpace(pidType);
00074 void *vmmGetFreeVirtualPage(pidType,int,int);
00075 
00076 uInt32 vmm_getPhysicalAddr(uInt32);
00077 int    vmm_setPageAttributes(uInt32,uInt16);
00078 int    vmm_remapPage(uInt32,uInt32,uInt16);
00079 int    vmm_pagingInit();
00080 void  *vmm_getFreeMallocPage(uInt16 count);
00081 void   vmm_pageFault(uInt32,uInt32,uInt32);
00082 void  _vmm_pageFault();
00083 int mmap(struct thread *,struct mmap_args *);
00084 int obreak(struct thread *,struct obreak_args *);
00085 int munmap(struct thread *,struct munmap_args *);
00086 
00087 
00088 extern uInt32 *kernelPageDirectory;
00089 
00090 #endif
00091 
00092 
00093 
00094 
00095