]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/sun4v/include/tte_hash.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / sun4v / include / tte_hash.h
1 /*-
2  * Copyright (c) 2006 Kip Macy
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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.
13  *
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
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #ifndef _MACHINE_TTE_HASH_H_
30 #define _MACHINE_TTE_HASH_H_
31
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)  
39
40
41 struct tte_hash;
42 typedef struct tte_hash *tte_hash_t;
43
44 void tte_hash_init(void);
45
46 void tte_hash_clear(tte_hash_t hash);
47
48 tte_t tte_hash_clear_bits(tte_hash_t hash, vm_offset_t va, uint64_t flags);
49
50 tte_hash_t tte_hash_kernel_create(vm_offset_t, uint16_t, vm_paddr_t);
51
52 tte_hash_t tte_hash_create(uint64_t context, uint64_t *scratchval);
53
54 void tte_hash_destroy(tte_hash_t th);
55
56 tte_t tte_hash_delete(tte_hash_t hash, vm_offset_t va);
57
58 void tte_hash_delete_all(tte_hash_t hash);
59
60 void tte_hash_insert(tte_hash_t hash, vm_offset_t va, tte_t data);
61
62 tte_t tte_hash_lookup(tte_hash_t hash, vm_offset_t va);
63
64 tte_t tte_hash_lookup_nolock(tte_hash_t hash, vm_offset_t va);
65
66 tte_hash_t tte_hash_reset(tte_hash_t hash, uint64_t *scratchval);
67
68 uint64_t tte_hash_set_scratchpad_kernel(tte_hash_t th);
69
70 uint64_t tte_hash_set_scratchpad_user(tte_hash_t th, uint64_t context);
71
72 tte_t tte_hash_update(tte_hash_t hash, vm_offset_t va, tte_t tte_data);
73
74 int tte_hash_needs_resize(tte_hash_t th);
75
76 tte_hash_t  tte_hash_resize(tte_hash_t th);
77
78 #endif /* _MACHINE_TTE_HASH_H_ */