ia64/xen-unstable

view xen/include/xen/lib.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 50634c215234
line source
1 #ifndef __LIB_H__
2 #define __LIB_H__
4 #include <xen/inttypes.h>
5 #include <xen/stdarg.h>
6 #include <xen/config.h>
7 #include <xen/types.h>
8 #include <xen/xmalloc.h>
9 #include <xen/string.h>
10 #include <asm/bug.h>
12 void __bug(char *file, int line) __attribute__((noreturn));
13 void __warn(char *file, int line);
15 #define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0)
16 #define WARN_ON(p) do { if (unlikely(p)) WARN(); } while (0)
18 /* Force a compilation error if condition is true */
19 #define BUILD_BUG_ON(condition) ((void)sizeof(struct { int:-!!(condition); }))
21 /* Force a compilation error if condition is true, but also produce a
22 result (of value 0 and type size_t), so the expression can be used
23 e.g. in a structure initializer (or where-ever else comma expressions
24 aren't permitted). */
25 #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
27 #ifndef assert_failed
28 #define assert_failed(p) \
29 do { \
30 printk("Assertion '%s' failed, line %d, file %s\n", #p , \
31 __LINE__, __FILE__); \
32 BUG(); \
33 } while (0)
34 #endif
36 #ifndef NDEBUG
37 #define ASSERT(p) \
38 do { if ( unlikely(!(p)) ) assert_failed(p); } while (0)
39 #else
40 #define ASSERT(p) ((void)0)
41 #endif
43 #define SWAP(_a, _b) \
44 do { typeof(_a) _t = (_a); (_a) = (_b); (_b) = _t; } while ( 0 )
46 #define DIV_ROUND(x, y) (((x) + (y) / 2) / (y))
48 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]) + __must_be_array(x))
50 #define reserve_bootmem(_p,_l) ((void)0)
52 struct domain;
54 void cmdline_parse(char *cmdline);
56 /*#define DEBUG_TRACE_DUMP*/
57 #ifdef DEBUG_TRACE_DUMP
58 extern void debugtrace_dump(void);
59 extern void debugtrace_printk(const char *fmt, ...);
60 #else
61 #define debugtrace_dump() ((void)0)
62 #define debugtrace_printk(_f, ...) ((void)0)
63 #endif
65 /* Allows us to use '%p' as general-purpose machine-word format char. */
66 #define _p(_x) ((void *)(unsigned long)(_x))
67 extern void printk(const char *format, ...)
68 __attribute__ ((format (printf, 1, 2)));
69 extern void panic(const char *format, ...)
70 __attribute__ ((format (printf, 1, 2)));
71 extern long vm_assist(struct domain *, unsigned int, unsigned int);
72 extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst);
73 extern int printk_ratelimit(void);
75 /* vsprintf.c */
76 #define sprintf __xen_has_no_sprintf__
77 #define vsprintf __xen_has_no_vsprintf__
78 extern int snprintf(char * buf, size_t size, const char * fmt, ...)
79 __attribute__ ((format (printf, 3, 4)));
80 extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
81 __attribute__ ((format (printf, 3, 0)));
82 extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
83 __attribute__ ((format (printf, 3, 4)));
84 extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
85 __attribute__ ((format (printf, 3, 0)));
86 extern int sscanf(const char * buf, const char * fmt, ...)
87 __attribute__ ((format (scanf, 2, 3)));
88 extern int vsscanf(const char * buf, const char * fmt, va_list args)
89 __attribute__ ((format (scanf, 2, 0)));
91 long simple_strtol(
92 const char *cp,const char **endp, unsigned int base);
93 unsigned long simple_strtoul(
94 const char *cp,const char **endp, unsigned int base);
95 long long simple_strtoll(
96 const char *cp,const char **endp, unsigned int base);
97 unsigned long long simple_strtoull(
98 const char *cp,const char **endp, unsigned int base);
100 unsigned long long parse_size_and_unit(const char *s, const char **ps);
102 #define TAINT_UNSAFE_SMP (1<<0)
103 #define TAINT_MACHINE_CHECK (1<<1)
104 #define TAINT_BAD_PAGE (1<<2)
105 #define TAINT_SYNC_CONSOLE (1<<3)
106 #define TAINT_ERROR_INJECT (1<<4)
107 extern int tainted;
108 #define TAINT_STRING_MAX_LEN 20
109 extern char *print_tainted(char *str);
110 extern void add_taint(unsigned);
112 #endif /* __LIB_H__ */