page_pt.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006 Jakub Jermar
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00035 /*
00036  * This is the generic 4-level page table interface.
00037  * Architectures that use hierarchical page tables
00038  * are supposed to implement *_ARCH macros.
00039  */
00040 
00041 #ifdef CONFIG_PAGE_PT
00042 
00043 #ifndef __PAGE_PT_H__
00044 #define __PAGE_PT_H__
00045 
00046 #include <arch/types.h>
00047 #include <typedefs.h>
00048 #include <mm/page.h>
00049 
00050 /*
00051  * Number of entries in each level.
00052  */
00053 #define PTL0_ENTRIES                    PTL0_ENTRIES_ARCH
00054 #define PTL1_ENTRIES                    PTL1_ENTRIES_ARCH
00055 #define PTL2_ENTRIES                    PTL2_ENTRIES_ARCH
00056 #define PTL3_ENTRIES                    PTL3_ENTRIES_ARCH
00057 
00058 /*
00059  * These macros process vaddr and extract those portions
00060  * of it that function as indices to respective page tables.
00061  */
00062 #define PTL0_INDEX(vaddr)               PTL0_INDEX_ARCH(vaddr)
00063 #define PTL1_INDEX(vaddr)               PTL1_INDEX_ARCH(vaddr)
00064 #define PTL2_INDEX(vaddr)               PTL2_INDEX_ARCH(vaddr)
00065 #define PTL3_INDEX(vaddr)               PTL3_INDEX_ARCH(vaddr)
00066 
00067 #define SET_PTL0_ADDRESS(ptl0)          SET_PTL0_ADDRESS_ARCH(ptl0)
00068 
00069 /*
00070  * These macros traverse the 4-level tree of page tables,
00071  * each descending by one level.
00072  */
00073 #define GET_PTL1_ADDRESS(ptl0, i)       GET_PTL1_ADDRESS_ARCH(ptl0, i)
00074 #define GET_PTL2_ADDRESS(ptl1, i)       GET_PTL2_ADDRESS_ARCH(ptl1, i)
00075 #define GET_PTL3_ADDRESS(ptl2, i)       GET_PTL3_ADDRESS_ARCH(ptl2, i)
00076 #define GET_FRAME_ADDRESS(ptl3, i)      GET_FRAME_ADDRESS_ARCH(ptl3, i)
00077 
00078 /*
00079  * These macros are provided to change shape of the 4-level
00080  * tree of page tables on respective level.
00081  */
00082 #define SET_PTL1_ADDRESS(ptl0, i, a)    SET_PTL1_ADDRESS_ARCH(ptl0, i, a)
00083 #define SET_PTL2_ADDRESS(ptl1, i, a)    SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
00084 #define SET_PTL3_ADDRESS(ptl2, i, a)    SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
00085 #define SET_FRAME_ADDRESS(ptl3, i, a)   SET_FRAME_ADDRESS_ARCH(ptl3, i, a)
00086 
00087 /*
00088  * These macros are provided to query various flags within the page tables.
00089  */
00090 #define GET_PTL1_FLAGS(ptl0, i)         GET_PTL1_FLAGS_ARCH(ptl0, i)
00091 #define GET_PTL2_FLAGS(ptl1, i)         GET_PTL2_FLAGS_ARCH(ptl1, i)
00092 #define GET_PTL3_FLAGS(ptl2, i)         GET_PTL3_FLAGS_ARCH(ptl2, i)
00093 #define GET_FRAME_FLAGS(ptl3, i)        GET_FRAME_FLAGS_ARCH(ptl3, i)
00094 
00095 /*
00096  * These macros are provided to set/clear various flags within the page tables.
00097  */
00098 #define SET_PTL1_FLAGS(ptl0, i, x)      SET_PTL1_FLAGS_ARCH(ptl0, i, x)
00099 #define SET_PTL2_FLAGS(ptl1, i, x)      SET_PTL2_FLAGS_ARCH(ptl1, i, x)
00100 #define SET_PTL3_FLAGS(ptl2, i, x)      SET_PTL3_FLAGS_ARCH(ptl2, i, x)
00101 #define SET_FRAME_FLAGS(ptl3, i, x)     SET_FRAME_FLAGS_ARCH(ptl3, i, x)
00102 
00103 #define PTE_VALID(p)            PTE_VALID_ARCH((p))
00104 #define PTE_PRESENT(p)          PTE_PRESENT_ARCH((p))
00105 #define PTE_GET_FRAME(p)        PTE_GET_FRAME_ARCH((p))
00106 #define PTE_READABLE(p)         1
00107 #define PTE_WRITABLE(p)         PTE_WRITABLE_ARCH((p))
00108 #define PTE_EXECUTABLE(p)       PTE_EXECUTABLE_ARCH((p))
00109 
00110 extern page_mapping_operations_t pt_mapping_operations;
00111 
00112 extern void page_mapping_insert_pt(as_t *as, __address page, __address frame, int flags);
00113 extern pte_t *page_mapping_find_pt(as_t *as, __address page);
00114 
00115 #endif
00116 
00117 #endif
00118 

Generated on Sun Jun 18 16:38:50 2006 for HelenOS Kernel (ia32) by  doxygen 1.4.6