ia64/xen-unstable

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