Subversion Repositories HelenOS

Rev

Rev 2787 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2787 Rev 4692
Line 49... Line 49...
49
#include <debug.h>
49
#include <debug.h>
50
#include <memstr.h>
50
#include <memstr.h>
51
#include <adt/hash_table.h>
51
#include <adt/hash_table.h>
52
#include <align.h>
52
#include <align.h>
53
 
53
 
54
static index_t hash(unative_t key[]);
54
static size_t hash(unative_t key[]);
55
static bool compare(unative_t key[], count_t keys, link_t *item);
55
static bool compare(unative_t key[], size_t keys, link_t *item);
56
static void remove_callback(link_t *item);
56
static void remove_callback(link_t *item);
57
 
57
 
58
static void ht_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
58
static void ht_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
59
    int flags);
59
    int flags);
60
static void ht_mapping_remove(as_t *as, uintptr_t page);
60
static void ht_mapping_remove(as_t *as, uintptr_t page);
Line 91... Line 91...
91
 *
91
 *
92
 * @param key Array of two keys (i.e. page and address space).
92
 * @param key Array of two keys (i.e. page and address space).
93
 *
93
 *
94
 * @return Index into page hash table.
94
 * @return Index into page hash table.
95
 */
95
 */
96
index_t hash(unative_t key[])
96
size_t hash(unative_t key[])
97
{
97
{
98
    as_t *as = (as_t *) key[KEY_AS];
98
    as_t *as = (as_t *) key[KEY_AS];
99
    uintptr_t page = (uintptr_t) key[KEY_PAGE];
99
    uintptr_t page = (uintptr_t) key[KEY_PAGE];
100
    index_t index;
100
    size_t index;
101
   
101
   
102
    /*
102
    /*
103
     * Virtual page addresses have roughly the same probability
103
     * Virtual page addresses have roughly the same probability
104
     * of occurring. Least significant bits of VPN compose the
104
     * of occurring. Least significant bits of VPN compose the
105
     * hash index.
105
     * hash index.
Line 122... Line 122...
122
 * @param keys Number of keys passed.
122
 * @param keys Number of keys passed.
123
 * @param item Item to compare the keys with.
123
 * @param item Item to compare the keys with.
124
 *
124
 *
125
 * @return true on match, false otherwise.
125
 * @return true on match, false otherwise.
126
 */
126
 */
127
bool compare(unative_t key[], count_t keys, link_t *item)
127
bool compare(unative_t key[], size_t keys, link_t *item)
128
{
128
{
129
    pte_t *t;
129
    pte_t *t;
130
 
130
 
131
    ASSERT(item);
131
    ASSERT(item);
132
    ASSERT((keys > 0) && (keys <= PAGE_HT_KEYS));
132
    ASSERT((keys > 0) && (keys <= PAGE_HT_KEYS));
Line 190... Line 190...
190
        t->x = (flags & PAGE_EXEC) != 0;
190
        t->x = (flags & PAGE_EXEC) != 0;
191
        t->w = (flags & PAGE_WRITE) != 0;
191
        t->w = (flags & PAGE_WRITE) != 0;
192
        t->k = !(flags & PAGE_USER);
192
        t->k = !(flags & PAGE_USER);
193
        t->c = (flags & PAGE_CACHEABLE) != 0;
193
        t->c = (flags & PAGE_CACHEABLE) != 0;
194
        t->p = !(flags & PAGE_NOT_PRESENT);
194
        t->p = !(flags & PAGE_NOT_PRESENT);
-
 
195
        t->a = false;
-
 
196
        t->d = false;
195
 
197
 
196
        t->as = as;
198
        t->as = as;
197
        t->page = ALIGN_DOWN(page, PAGE_SIZE);
199
        t->page = ALIGN_DOWN(page, PAGE_SIZE);
198
        t->frame = ALIGN_DOWN(frame, FRAME_SIZE);
200
        t->frame = ALIGN_DOWN(frame, FRAME_SIZE);
199
 
201