ia64/xen-unstable

view xen/include/xen/radix-tree.h @ 19800:78962f85c562

IOMMU: Add two generic functions to vendor neutral interface

Add 2 generic functions into the vendor neutral iommu interface, The
reason is that from changeset 19732, there is only one global flag
"iommu_enabled" that controls iommu enablement for both vtd and amd
systems, so we need different code paths for vtd and amd iommu systems
if this flag has been turned on. Also, the early checking of
"iommu_enabled" in iommu_setup() is removed to prevent iommu
functionalities from been disabled on amd systems.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 19 08:41:50 2009 +0100 (2009-06-19)
parents f210a633571c
children
line source
1 /*
2 * Copyright (C) 2001 Momchil Velikov
3 * Portions Copyright (C) 2001 Christoph Hellwig
4 * Adapted for Xen by Dan Magenheimer, Oracle Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2, or (at
9 * your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 #ifndef _XEN_RADIX_TREE_H
21 #define _XEN_RADIX_TREE_H
23 /* root tags are stored in gfp_mask, shifted by __GFP_BITS_SHIFT */
24 struct radix_tree_root {
25 unsigned int height;
26 struct radix_tree_node *rnode;
27 };
29 #define RADIX_TREE_MAP_SHIFT 6
31 #define RADIX_TREE_MAP_SIZE (1UL << RADIX_TREE_MAP_SHIFT)
32 #define RADIX_TREE_MAP_MASK (RADIX_TREE_MAP_SIZE-1)
34 #define RADIX_TREE_TAG_LONGS \
35 ((RADIX_TREE_MAP_SIZE + BITS_PER_LONG - 1) / BITS_PER_LONG)
37 struct radix_tree_node {
38 unsigned int count;
39 void *slots[RADIX_TREE_MAP_SIZE];
40 };
42 struct radix_tree_path {
43 struct radix_tree_node *node;
44 int offset;
45 };
47 #define RADIX_TREE_INDEX_BITS (8 /* CHAR_BIT */ * sizeof(unsigned long))
48 #define RADIX_TREE_MAX_PATH (RADIX_TREE_INDEX_BITS/RADIX_TREE_MAP_SHIFT + 2)
51 #define RADIX_TREE_INIT(mask) { \
52 .height = 0, \
53 .rnode = NULL, \
54 }
56 #define RADIX_TREE(name, mask) \
57 struct radix_tree_root name = RADIX_TREE_INIT(mask)
59 #define INIT_RADIX_TREE(root, mask) \
60 do { \
61 (root)->height = 0; \
62 (root)->rnode = NULL; \
63 } while (0)
65 int radix_tree_insert(struct radix_tree_root *root, unsigned long index,
66 void *item, struct radix_tree_node *(*node_alloc)(void *), void *arg);
67 void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
68 void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long);
69 void radix_tree_destroy(struct radix_tree_root *root,
70 void (*slot_free)(void *), void (*node_free)(struct radix_tree_node *));
71 void *radix_tree_delete(struct radix_tree_root *root, unsigned long index,
72 void(*node_free)(struct radix_tree_node *));
73 unsigned int
74 radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
75 unsigned long first_index, unsigned int max_items);
76 void radix_tree_init(void);
78 #endif /* _XEN_RADIX_TREE_H */