2 * Copyright (c) 2006 Kip Macy
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifndef _MACHINE_TTE_HASH_H_
30 #define _MACHINE_TTE_HASH_H_
32 #define HASH_ENTRY_SHIFT 2
33 #define HASH_ENTRIES ((1 << HASH_ENTRY_SHIFT) - 1)
34 #define THE_SHIFT (TTE_SHIFT + HASH_ENTRY_SHIFT) /* size of TSB entry * #entries */
35 #define TH_COLLISION_SHIFT 47 /* bit 47 will never be set for a valid tag */
36 #define TH_COLLISION (1UL << TH_COLLISION_SHIFT)
37 #define TH_INVALID_SHIFT 46 /* bit 47 will never be set for a valid tag */
38 #define TH_INVALID (1UL << TH_INVALID_SHIFT)
42 typedef struct tte_hash *tte_hash_t;
44 void tte_hash_init(void);
46 void tte_hash_clear(tte_hash_t hash);
48 tte_t tte_hash_clear_bits(tte_hash_t hash, vm_offset_t va, uint64_t flags);
50 tte_hash_t tte_hash_kernel_create(vm_offset_t, uint16_t, vm_paddr_t);
52 tte_hash_t tte_hash_create(uint64_t context, uint64_t *scratchval);
54 void tte_hash_destroy(tte_hash_t th);
56 tte_t tte_hash_delete(tte_hash_t hash, vm_offset_t va);
58 void tte_hash_delete_all(tte_hash_t hash);
60 void tte_hash_insert(tte_hash_t hash, vm_offset_t va, tte_t data);
62 tte_t tte_hash_lookup(tte_hash_t hash, vm_offset_t va);
64 tte_t tte_hash_lookup_nolock(tte_hash_t hash, vm_offset_t va);
66 tte_hash_t tte_hash_reset(tte_hash_t hash, uint64_t *scratchval);
68 uint64_t tte_hash_set_scratchpad_kernel(tte_hash_t th);
70 uint64_t tte_hash_set_scratchpad_user(tte_hash_t th, uint64_t context);
72 tte_t tte_hash_update(tte_hash_t hash, vm_offset_t va, tte_t tte_data);
74 int tte_hash_needs_resize(tte_hash_t th);
76 tte_hash_t tte_hash_resize(tte_hash_t th);
78 #endif /* _MACHINE_TTE_HASH_H_ */