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 page hash table interface. 00037 */ 00038 00039 #ifdef CONFIG_PAGE_HT 00040 00041 #ifndef __PAGE_HT_H__ 00042 #define __PAGE_HT_H__ 00043 00044 #include <mm/page.h> 00045 #include <typedefs.h> 00046 #include <arch/types.h> 00047 #include <adt/list.h> 00048 #include <adt/hash_table.h> 00049 00050 #define PAGE_HT_KEYS 2 00051 #define KEY_AS 0 00052 #define KEY_PAGE 1 00053 00054 #define PAGE_HT_ENTRIES_BITS 13 00055 #define PAGE_HT_ENTRIES (1<<PAGE_HT_ENTRIES_BITS) 00056 00057 #define PTE_VALID(pte) ((pte) != NULL) 00058 #define PTE_PRESENT(pte) ((pte)->p != 0) 00059 #define PTE_GET_FRAME(pte) ((pte)->frame) 00060 #define PTE_READABLE(pte) 1 00061 #define PTE_WRITABLE(pte) ((pte)->w != 0) 00062 #define PTE_EXECUTABLE(pte) ((pte)->x != 0) 00063 00064 #define SET_PTL0_ADDRESS(x) 00065 00066 struct pte { 00067 link_t link; 00068 as_t *as; 00069 __address page; 00070 __address frame; 00071 unsigned g : 1; 00072 unsigned x : 1; 00073 unsigned w : 1; 00074 unsigned k : 1; 00075 unsigned c : 1; 00076 unsigned a : 1; 00077 unsigned d : 1; 00078 unsigned p : 1; 00079 }; 00080 00081 extern page_mapping_operations_t ht_mapping_operations; 00082 extern mutex_t page_ht_lock; 00083 extern hash_table_t page_ht; 00084 extern hash_table_operations_t ht_operations; 00085 00086 #endif 00087 00088 #endif 00089