]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Error code constants for selector-based error codes
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 8 Jan 2016 19:11:59 +0000 (19:11 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 11 Jan 2016 17:34:55 +0000 (17:34 +0000)
Provide symbolic constant support as well.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
include/arch/x86/processor.h
include/arch/x86/symbolic-const.h

index d1346f6f5bbaad959595115e988f3e3fb4693a9e..62ea832d64321e0f4a01e60da665b7557266ab72 100644 (file)
 /* Number of reserved vectors for exceptions. */
 #define X86_NR_RESERVED_VECTORS 32
 
+/*
+ * Error Code mnemonics.
+ */
+/* Segment-based Error Code - architecturally defined. */
+#define X86_EC_EXT (1U << 0) /* External event. */
+#define X86_EC_IDT (1U << 1) /* Descriptor Location.  IDT, or LDT/GDT */
+#define X86_EC_TI  (1U << 2) /* Only if !IDT.  LDT or GDT. */
+
+/* Segment-based Error Code - supplemental constants. */
+#define X86_EC_TABLE_MASK (3U << 1)
+#define X86_EC_SEL_MASK   (-1L << 3)
+#define X86_EC_GDT        0
+#define X86_EC_LDT        X86_EC_TI
+
 #endif /* XTF_X86_PROCESSOR_H */
 
 /*
index 2aa1ecab08b5b97b6470984a92ad8b3ed5d731f6..9d762a3948809f539887001a54eedbfa24ae5a91 100644 (file)
@@ -9,6 +9,7 @@
 #include <xtf/macro_magic.h>
 
 #include <arch/x86/desc.h>
+#include <arch/x86/processor.h>
 
 /**
  * Tokenise and OR together.
 #define INIT_GDTE_SYM(base, limit, ...) \
     INIT_GDTE(base, limit, TOK_OR(SEG_ATTR_, ##__VA_ARGS__))
 
+/**
+ * Create a selector based error code using X86_EC_ mnemonics.
+ *
+ * @param sel Selector value.
+ * @param ... Partial X86_EC_ tokens.
+ *
+ * Example usage:
+ * - EXC_EC_SYM(0, GDT)
+ *   - Uses @ref X86_EC_GDT.
+ *
+ * - EXC_EC_SYM(0, IDT, EXT)
+ *   - Uses @ref X86_EC_IDT and @ref X86_EC_EXT.
+ */
+#define SEL_EC_SYM(sel, ...) (sel | TOK_OR(X86_EC_, ##__VA_ARGS__))
+
+/**
+ * Create an exception selector based error code using mnemonics, with
+ * implicit @ref X86_EC_IDT.
+ *
+ * @param exc Partial X86_EXC_ token for selector.
+ * @param ... Partial X86_EC_ tokens.
+ *
+ * Example usage:
+ * - EXC_EC_SYM(DE)
+ *   - Uses @ref X86_EXC_DE and @ref X86_EC_IDT.
+ *
+ * - EXC_EC_SYM(DB, EXT)
+ *   - Uses @ref X86_EXC_DB, @ref X86_EC_IDT and @ref X86_EC_EXT.
+ */
+#define EXC_EC_SYM(exc, ...) \
+    SEL_EC_SYM(((X86_EXC_ ## exc) << 3), IDT, ##__VA_ARGS__)
+
 #endif /* XTF_X86_SYMBOLIC_CONST_H */
 
 /*