# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1201454756 0
# Node ID afa521cf82e68cb170ce8b536d8f968e2dc4eba6
# Parent 226de1674b2fea24413c54f43e2588907864e9bd
Move remaining xen/include/public/foreign files to tools/include/xen-foreign
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
xen/include/public/foreign/mkchecker.py | 54 ---------
xen/include/public/foreign/mkheader.py | 167 ------------------------------
xen/include/public/foreign/reference.size | 18 ---
xen/include/public/foreign/structs.py | 58 ----------
tools/include/xen-foreign/Makefile | 14 --
tools/include/xen-foreign/mkchecker.py | 53 +++++++++
tools/include/xen-foreign/mkheader.py | 167 ++++++++++++++++++++++++++++++
tools/include/xen-foreign/reference.size | 18 +++
tools/include/xen-foreign/structs.py | 58 ++++++++++
9 files changed, 301 insertions(+), 306 deletions(-)
diff -r 226de1674b2f -r afa521cf82e6 tools/include/xen-foreign/Makefile
--- a/tools/include/xen-foreign/Makefile Sun Jan 27 17:05:47 2008 +0000
+++ b/tools/include/xen-foreign/Makefile Sun Jan 27 17:25:56 2008 +0000
@@ -2,10 +2,6 @@ include $(XEN_ROOT)/Config.mk
include $(XEN_ROOT)/Config.mk
ROOT = $(XEN_ROOT)/xen/include/public
-HOSTCFLAGS += -I$(ROOT)/foreign
-
-MKCHECKER_PY = $(ROOT)/foreign/mkchecker.py
-MKHEADER_PY = $(ROOT)/foreign/mkheader.py
architectures := x86_32 x86_64 ia64
headers := $(patsubst %, %.h, $(architectures))
@@ -23,17 +19,17 @@ checker: checker.c $(headers)
check-headers: checker
./checker > tmp.size
- diff -u $(ROOT)/foreign/reference.size tmp.size
+ diff -u reference.size tmp.size
rm tmp.size
-x86_32.h: $(MKHEADER_PY) $(ROOT)/arch-x86/xen-x86_32.h $(ROOT)/arch-x86/xen.h
$(ROOT)/xen.h
+x86_32.h: mkheader.py $(ROOT)/arch-x86/xen-x86_32.h $(ROOT)/arch-x86/xen.h
$(ROOT)/xen.h
python $< $* $@ $(filter %.h,$^)
-x86_64.h: $(MKHEADER_PY) $(ROOT)/arch-x86/xen-x86_64.h $(ROOT)/arch-x86/xen.h
$(ROOT)/xen.h
+x86_64.h: mkheader.py $(ROOT)/arch-x86/xen-x86_64.h $(ROOT)/arch-x86/xen.h
$(ROOT)/xen.h
python $< $* $@ $(filter %.h,$^)
-ia64.h: $(MKHEADER_PY) $(ROOT)/arch-ia64.h $(ROOT)/xen.h
+ia64.h: mkheader.py $(ROOT)/arch-ia64.h $(ROOT)/xen.h
python $< $* $@ $(filter %.h,$^)
-checker.c: $(MKCHECKER_PY)
+checker.c: mkchecker.py
python $< $@ $(architectures)
diff -r 226de1674b2f -r afa521cf82e6 tools/include/xen-foreign/mkchecker.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/include/xen-foreign/mkchecker.py Sun Jan 27 17:25:56 2008 +0000
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+
+import sys;
+from structs import structs;
+
+# command line arguments
+outfile = sys.argv[1];
+archs = sys.argv[2:];
+
+f = open(outfile, "w");
+f.write('''
+/*
+ * sanity checks for generated foreign headers:
+ * - verify struct sizes
+ *
+ * generated by %s -- DO NOT EDIT
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <inttypes.h>
+''');
+
+for a in archs:
+ f.write('#include "%s.h"\n' % a);
+
+f.write('int main(int argc, char *argv[])\n{\n');
+
+f.write('\tprintf("\\n");');
+f.write('printf("%-25s |", "structs");\n');
+for a in archs:
+ f.write('\tprintf("%%8s", "%s");\n' % a);
+f.write('\tprintf("\\n");');
+
+f.write('\tprintf("\\n");');
+for struct in structs:
+ f.write('\tprintf("%%-25s |", "%s");\n' % struct);
+ for a in archs:
+ s = struct + "_" + a;
+ f.write('#ifdef %s_has_no_%s\n' % (a, struct));
+ f.write('\tprintf("%8s", "-");\n');
+ f.write("#else\n");
+ f.write('\tprintf("%%8zd", sizeof(struct %s));\n' % s);
+ f.write("#endif\n");
+
+ f.write('\tprintf("\\n");\n\n');
+
+f.write('\tprintf("\\n");\n');
+f.write('\texit(0);\n');
+f.write('}\n');
+
+f.close();
+
diff -r 226de1674b2f -r afa521cf82e6 tools/include/xen-foreign/mkheader.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/include/xen-foreign/mkheader.py Sun Jan 27 17:25:56 2008 +0000
@@ -0,0 +1,167 @@
+#!/usr/bin/python
+
+import sys, re;
+from structs import unions, structs, defines;
+
+# command line arguments
+arch = sys.argv[1];
+outfile = sys.argv[2];
+infiles = sys.argv[3:];
+
+
+###########################################################################
+# configuration #2: architecture information
+
+inttypes = {};
+header = {};
+footer = {};
+
+# x86_32
+inttypes["x86_32"] = {
+ "unsigned long" : "uint32_t",
+ "long" : "uint32_t",
+ "xen_pfn_t" : "uint32_t",
+};
+header["x86_32"] = """
+#define __i386___X86_32 1
+#pragma pack(4)
+""";
+footer["x86_32"] = """
+#pragma pack()
+""";
+
+# x86_64
+inttypes["x86_64"] = {
+ "unsigned long" : "__align8__ uint64_t",
+ "long" : "__align8__ uint64_t",
+ "xen_pfn_t" : "__align8__ uint64_t",
+};
+header["x86_64"] = """
+#ifdef __GNUC__
+# define __DECL_REG(name) union { uint64_t r ## name, e ## name; }
+# define __align8__ __attribute__((aligned (8)))
+#else
+# define __DECL_REG(name) uint64_t r ## name
+# define __align8__ FIXME
+#endif
+#define __x86_64___X86_64 1
+""";
+
+# ia64
+inttypes["ia64"] = {
+ "unsigned long" : "__align8__ uint64_t",
+ "long" : "__align8__ uint64_t",
+ "xen_pfn_t" : "__align8__ uint64_t",
+ "long double" : "__align16__ ldouble_t",
+};
+header["ia64"] = """
+#define __align8__ __attribute__((aligned (8)))
+#define __align16__ __attribute__((aligned (16)))
+typedef unsigned char ldouble_t[16];
+""";
+
+
+###########################################################################
+# main
+
+input = "";
+output = "";
+fileid = re.sub("[-.]", "_", "__FOREIGN_%s__" % outfile.upper());
+
+# read input header files
+for name in infiles:
+ f = open(name, "r");
+ input += f.read();
+ f.close();
+
+# add header
+output += """
+/*
+ * public xen defines and struct for %s
+ * generated by %s -- DO NOT EDIT
+ */
+
+#ifndef %s
+#define %s 1
+
+""" % (arch, sys.argv[0], fileid, fileid)
+
+if arch in header:
+ output += header[arch];
+ output += "\n";
+
+# add defines to output
+for line in re.findall("#define[^\n]+", input):
+ for define in defines:
+ regex = "#define\s+%s\\b" % define;
+ match = re.search(regex, line);
+ if None == match:
+ continue;
+ if define.upper()[0] == define[0]:
+ replace = define + "_" + arch.upper();
+ else:
+ replace = define + "_" + arch;
+ regex = "\\b%s\\b" % define;
+ output += re.sub(regex, replace, line) + "\n";
+output += "\n";
+
+# delete defines, comments, empty lines
+input = re.sub("#define[^\n]+\n", "", input);
+input = re.compile("/\*(.*?)\*/", re.S).sub("", input)
+input = re.compile("\n\s*\n", re.S).sub("\n", input);
+
+# add unions to output
+for union in unions:
+ regex = "union\s+%s\s*\{(.*?)\n\};" % union;
+ match = re.search(regex, input, re.S)
+ if None == match:
+ output += "#define %s_has_no_%s 1\n" % (arch, union);
+ else:
+ output += "union %s_%s {%s\n};\n" % (union, arch, match.group(1));
+ output += "\n";
+
+# add structs to output
+for struct in structs:
+ regex = "struct\s+%s\s*\{(.*?)\n\};" % struct;
+ match = re.search(regex, input, re.S)
+ if None == match:
+ output += "#define %s_has_no_%s 1\n" % (arch, struct);
+ else:
+ output += "struct %s_%s {%s\n};\n" % (struct, arch, match.group(1));
+ output += "typedef struct %s_%s %s_%s_t;\n" % (struct, arch, struct,
arch);
+ output += "\n";
+
+# add footer
+if arch in footer:
+ output += footer[arch];
+ output += "\n";
+output += "#endif /* %s */\n" % fileid;
+
+# replace: defines
+for define in defines:
+ if define.upper()[0] == define[0]:
+ replace = define + "_" + arch.upper();
+ else:
+ replace = define + "_" + arch;
+ output = re.sub("\\b%s\\b" % define, replace, output);
+
+# replace: unions
+for union in unions:
+ output = re.sub("\\b(union\s+%s)\\b" % union, "\\1_%s" % arch, output);
+
+# replace: structs + struct typedefs
+for struct in structs:
+ output = re.sub("\\b(struct\s+%s)\\b" % struct, "\\1_%s" % arch, output);
+ output = re.sub("\\b(%s)_t\\b" % struct, "\\1_%s_t" % arch, output);
+
+# replace: integer types
+integers = inttypes[arch].keys();
+integers.sort(lambda a, b: cmp(len(b),len(a)));
+for type in integers:
+ output = re.sub("\\b%s\\b" % type, inttypes[arch][type], output);
+
+# print results
+f = open(outfile, "w");
+f.write(output);
+f.close;
+
diff -r 226de1674b2f -r afa521cf82e6 tools/include/xen-foreign/reference.size
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/include/xen-foreign/reference.size Sun Jan 27 17:25:56 2008 +0000
@@ -0,0 +1,18 @@
+
+structs | x86_32 x86_64 ia64
+
+start_info | 1104 1152 1152
+trap_info | 8 16 -
+pt_fpreg | - - 16
+cpu_user_regs | 68 200 -
+xen_ia64_boot_param | - - 96
+ia64_tr_entry | - - 32
+vcpu_tr_regs | - - 768
+vcpu_guest_context_regs | - - 22176
+vcpu_guest_context | 2800 5168 22208
+arch_vcpu_info | 24 16 0
+vcpu_time_info | 32 32 32
+vcpu_info | 64 64 48
+arch_shared_info | 268 280 272
+shared_info | 2584 3368 4384
+
diff -r 226de1674b2f -r afa521cf82e6 tools/include/xen-foreign/structs.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/include/xen-foreign/structs.py Sun Jan 27 17:25:56 2008 +0000
@@ -0,0 +1,58 @@
+# configuration: what needs translation
+
+unions = [ "vcpu_cr_regs",
+ "vcpu_ar_regs" ];
+
+structs = [ "start_info",
+ "trap_info",
+ "pt_fpreg",
+ "cpu_user_regs",
+ "xen_ia64_boot_param",
+ "ia64_tr_entry",
+ "vcpu_tr_regs",
+ "vcpu_guest_context_regs",
+ "vcpu_guest_context",
+ "arch_vcpu_info",
+ "vcpu_time_info",
+ "vcpu_info",
+ "arch_shared_info",
+ "shared_info" ];
+
+defines = [ "__i386__",
+ "__x86_64__",
+
+ "FLAT_RING1_CS",
+ "FLAT_RING1_DS",
+ "FLAT_RING1_SS",
+
+ "FLAT_RING3_CS64",
+ "FLAT_RING3_DS64",
+ "FLAT_RING3_SS64",
+ "FLAT_KERNEL_CS64",
+ "FLAT_KERNEL_DS64",
+ "FLAT_KERNEL_SS64",
+
+ "FLAT_KERNEL_CS",
+ "FLAT_KERNEL_DS",
+ "FLAT_KERNEL_SS",
+
+ # x86_{32,64}
+ "_VGCF_i387_valid",
+ "VGCF_i387_valid",
+ "_VGCF_in_kernel",
+ "VGCF_in_kernel",
+ "_VGCF_failsafe_disables_events",
+ "VGCF_failsafe_disables_events",
+ "_VGCF_syscall_disables_events",
+ "VGCF_syscall_disables_events",
+ "_VGCF_online",
+ "VGCF_online",
+
+ # ia64
+ "VGCF_EXTRA_REGS",
+
+ # all archs
+ "xen_pfn_to_cr3",
+ "MAX_VIRT_CPUS",
+ "MAX_GUEST_CMDLINE" ];
+
diff -r 226de1674b2f -r afa521cf82e6 xen/include/public/foreign/mkchecker.py
--- a/xen/include/public/foreign/mkchecker.py Sun Jan 27 17:05:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#!/usr/bin/python
-
-import sys;
-from structs import structs;
-
-# command line arguments
-outfile = sys.argv[1];
-archs = sys.argv[2:];
-
-f = open(outfile, "w");
-f.write('''
-/*
- * sanity checks for generated foreign headers:
- * - verify struct sizes
- *
- * generated by %s -- DO NOT EDIT
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <inttypes.h>
-#include "../xen.h"
-''');
-
-for a in archs:
- f.write('#include "%s.h"\n' % a);
-
-f.write('int main(int argc, char *argv[])\n{\n');
-
-f.write('\tprintf("\\n");');
-f.write('printf("%-25s |", "structs");\n');
-for a in archs:
- f.write('\tprintf("%%8s", "%s");\n' % a);
-f.write('\tprintf("\\n");');
-
-f.write('\tprintf("\\n");');
-for struct in structs:
- f.write('\tprintf("%%-25s |", "%s");\n' % struct);
- for a in archs:
- s = struct + "_" + a;
- f.write('#ifdef %s_has_no_%s\n' % (a, struct));
- f.write('\tprintf("%8s", "-");\n');
- f.write("#else\n");
- f.write('\tprintf("%%8zd", sizeof(struct %s));\n' % s);
- f.write("#endif\n");
-
- f.write('\tprintf("\\n");\n\n');
-
-f.write('\tprintf("\\n");\n');
-f.write('\texit(0);\n');
-f.write('}\n');
-
-f.close();
-
diff -r 226de1674b2f -r afa521cf82e6 xen/include/public/foreign/mkheader.py
--- a/xen/include/public/foreign/mkheader.py Sun Jan 27 17:05:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-#!/usr/bin/python
-
-import sys, re;
-from structs import unions, structs, defines;
-
-# command line arguments
-arch = sys.argv[1];
-outfile = sys.argv[2];
-infiles = sys.argv[3:];
-
-
-###########################################################################
-# configuration #2: architecture information
-
-inttypes = {};
-header = {};
-footer = {};
-
-# x86_32
-inttypes["x86_32"] = {
- "unsigned long" : "uint32_t",
- "long" : "uint32_t",
- "xen_pfn_t" : "uint32_t",
-};
-header["x86_32"] = """
-#define __i386___X86_32 1
-#pragma pack(4)
-""";
-footer["x86_32"] = """
-#pragma pack()
-""";
-
-# x86_64
-inttypes["x86_64"] = {
- "unsigned long" : "__align8__ uint64_t",
- "long" : "__align8__ uint64_t",
- "xen_pfn_t" : "__align8__ uint64_t",
-};
-header["x86_64"] = """
-#ifdef __GNUC__
-# define __DECL_REG(name) union { uint64_t r ## name, e ## name; }
-# define __align8__ __attribute__((aligned (8)))
-#else
-# define __DECL_REG(name) uint64_t r ## name
-# define __align8__ FIXME
-#endif
-#define __x86_64___X86_64 1
-""";
-
-# ia64
-inttypes["ia64"] = {
- "unsigned long" : "__align8__ uint64_t",
- "long" : "__align8__ uint64_t",
- "xen_pfn_t" : "__align8__ uint64_t",
- "long double" : "__align16__ ldouble_t",
-};
-header["ia64"] = """
-#define __align8__ __attribute__((aligned (8)))
-#define __align16__ __attribute__((aligned (16)))
-typedef unsigned char ldouble_t[16];
-""";
-
-
-###########################################################################
-# main
-
-input = "";
-output = "";
-fileid = re.sub("[-.]", "_", "__FOREIGN_%s__" % outfile.upper());
-
-# read input header files
-for name in infiles:
- f = open(name, "r");
- input += f.read();
- f.close();
-
-# add header
-output += """
-/*
- * public xen defines and struct for %s
- * generated by %s -- DO NOT EDIT
- */
-
-#ifndef %s
-#define %s 1
-
-""" % (arch, sys.argv[0], fileid, fileid)
-
-if arch in header:
- output += header[arch];
- output += "\n";
-
-# add defines to output
-for line in re.findall("#define[^\n]+", input):
- for define in defines:
- regex = "#define\s+%s\\b" % define;
- match = re.search(regex, line);
- if None == match:
- continue;
- if define.upper()[0] == define[0]:
- replace = define + "_" + arch.upper();
- else:
- replace = define + "_" + arch;
- regex = "\\b%s\\b" % define;
- output += re.sub(regex, replace, line) + "\n";
-output += "\n";
-
-# delete defines, comments, empty lines
-input = re.sub("#define[^\n]+\n", "", input);
-input = re.compile("/\*(.*?)\*/", re.S).sub("", input)
-input = re.compile("\n\s*\n", re.S).sub("\n", input);
-
-# add unions to output
-for union in unions:
- regex = "union\s+%s\s*\{(.*?)\n\};" % union;
- match = re.search(regex, input, re.S)
- if None == match:
- output += "#define %s_has_no_%s 1\n" % (arch, union);
- else:
- output += "union %s_%s {%s\n};\n" % (union, arch, match.group(1));
- output += "\n";
-
-# add structs to output
-for struct in structs:
- regex = "struct\s+%s\s*\{(.*?)\n\};" % struct;
- match = re.search(regex, input, re.S)
- if None == match:
- output += "#define %s_has_no_%s 1\n" % (arch, struct);
- else:
- output += "struct %s_%s {%s\n};\n" % (struct, arch, match.group(1));
- output += "typedef struct %s_%s %s_%s_t;\n" % (struct, arch, struct,
arch);
- output += "\n";
-
-# add footer
-if arch in footer:
- output += footer[arch];
- output += "\n";
-output += "#endif /* %s */\n" % fileid;
-
-# replace: defines
-for define in defines:
- if define.upper()[0] == define[0]:
- replace = define + "_" + arch.upper();
- else:
- replace = define + "_" + arch;
- output = re.sub("\\b%s\\b" % define, replace, output);
-
-# replace: unions
-for union in unions:
- output = re.sub("\\b(union\s+%s)\\b" % union, "\\1_%s" % arch, output);
-
-# replace: structs + struct typedefs
-for struct in structs:
- output = re.sub("\\b(struct\s+%s)\\b" % struct, "\\1_%s" % arch, output);
- output = re.sub("\\b(%s)_t\\b" % struct, "\\1_%s_t" % arch, output);
-
-# replace: integer types
-integers = inttypes[arch].keys();
-integers.sort(lambda a, b: cmp(len(b),len(a)));
-for type in integers:
- output = re.sub("\\b%s\\b" % type, inttypes[arch][type], output);
-
-# print results
-f = open(outfile, "w");
-f.write(output);
-f.close;
-
diff -r 226de1674b2f -r afa521cf82e6 xen/include/public/foreign/reference.size
--- a/xen/include/public/foreign/reference.size Sun Jan 27 17:05:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-
-structs | x86_32 x86_64 ia64
-
-start_info | 1104 1152 1152
-trap_info | 8 16 -
-pt_fpreg | - - 16
-cpu_user_regs | 68 200 -
-xen_ia64_boot_param | - - 96
-ia64_tr_entry | - - 32
-vcpu_tr_regs | - - 768
-vcpu_guest_context_regs | - - 22176
-vcpu_guest_context | 2800 5168 22208
-arch_vcpu_info | 24 16 0
-vcpu_time_info | 32 32 32
-vcpu_info | 64 64 48
-arch_shared_info | 268 280 272
-shared_info | 2584 3368 4384
-
diff -r 226de1674b2f -r afa521cf82e6 xen/include/public/foreign/structs.py
--- a/xen/include/public/foreign/structs.py Sun Jan 27 17:05:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-# configuration: what needs translation
-
-unions = [ "vcpu_cr_regs",
- "vcpu_ar_regs" ];
-
-structs = [ "start_info",
- "trap_info",
- "pt_fpreg",
- "cpu_user_regs",
- "xen_ia64_boot_param",
- "ia64_tr_entry",
- "vcpu_tr_regs",
- "vcpu_guest_context_regs",
- "vcpu_guest_context",
- "arch_vcpu_info",
- "vcpu_time_info",
- "vcpu_info",
- "arch_shared_info",
- "shared_info" ];
-
-defines = [ "__i386__",
- "__x86_64__",
-
- "FLAT_RING1_CS",
- "FLAT_RING1_DS",
- "FLAT_RING1_SS",
-
- "FLAT_RING3_CS64",
- "FLAT_RING3_DS64",
- "FLAT_RING3_SS64",
- "FLAT_KERNEL_CS64",
- "FLAT_KERNEL_DS64",
- "FLAT_KERNEL_SS64",
-
- "FLAT_KERNEL_CS",
- "FLAT_KERNEL_DS",
- "FLAT_KERNEL_SS",
-
- # x86_{32,64}
- "_VGCF_i387_valid",
- "VGCF_i387_valid",
- "_VGCF_in_kernel",
- "VGCF_in_kernel",
- "_VGCF_failsafe_disables_events",
- "VGCF_failsafe_disables_events",
- "_VGCF_syscall_disables_events",
- "VGCF_syscall_disables_events",
- "_VGCF_online",
- "VGCF_online",
-
- # ia64
- "VGCF_EXTRA_REGS",
-
- # all archs
- "xen_pfn_to_cr3",
- "MAX_VIRT_CPUS",
- "MAX_GUEST_CMDLINE" ];
-
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|