ia64/xen-unstable

view xen/include/xen/kernel.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 60f91c9f1a24
children
line source
1 #ifndef _LINUX_KERNEL_H
2 #define _LINUX_KERNEL_H
4 /*
5 * 'kernel.h' contains some often-used function prototypes etc
6 */
8 /*
9 * min()/max() macros that also do
10 * strict type-checking.. See the
11 * "unnecessary" pointer comparison.
12 */
13 #define min(x,y) ({ \
14 const typeof(x) _x = (x); \
15 const typeof(y) _y = (y); \
16 (void) (&_x == &_y); \
17 _x < _y ? _x : _y; })
19 #define max(x,y) ({ \
20 const typeof(x) _x = (x); \
21 const typeof(y) _y = (y); \
22 (void) (&_x == &_y); \
23 _x > _y ? _x : _y; })
25 /*
26 * ..and if you can't take the strict
27 * types, you can specify one yourself.
28 *
29 * Or not use min/max at all, of course.
30 */
31 #define min_t(type,x,y) \
32 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
33 #define max_t(type,x,y) \
34 ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
36 /**
37 * container_of - cast a member of a structure out to the containing structure
38 *
39 * @ptr: the pointer to the member.
40 * @type: the type of the container struct this is embedded in.
41 * @member: the name of the member within the struct.
42 *
43 */
44 #define container_of(ptr, type, member) ({ \
45 typeof( ((type *)0)->member ) *__mptr = (ptr); \
46 (type *)( (char *)__mptr - offsetof(type,member) );})
48 /*
49 * Check at compile time that something is of a particular type.
50 * Always evaluates to 1 so you may use it easily in comparisons.
51 */
52 #define typecheck(type,x) \
53 ({ type __dummy; \
54 typeof(x) __dummy2; \
55 (void)(&__dummy == &__dummy2); \
56 1; \
57 })
59 extern char _start[], _end[];
60 #define is_kernel(p) ({ \
61 char *__p = (char *)(unsigned long)(p); \
62 (__p >= _start) && (__p <= _end); \
63 })
65 extern char _stext[], _etext[];
66 #define is_kernel_text(p) ({ \
67 char *__p = (char *)(unsigned long)(p); \
68 (__p >= _stext) && (__p <= _etext); \
69 })
71 extern char _sinittext[], _einittext[];
72 #define is_kernel_inittext(p) ({ \
73 char *__p = (char *)(unsigned long)(p); \
74 (__p >= _sinittext) && (__p <= _einittext); \
75 })
77 #endif /* _LINUX_KERNEL_H */