pci: assert configuration access is within bounds
[qemu/ar7.git] / scripts / tracetool / format / tcg_h.py
blob0180e3d76cfb5aa1c3a603469aec455788f8d120
1 # -*- coding: utf-8 -*-
3 """
4 Generate .h file for TCG code generation.
5 """
7 __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
8 __copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
9 __license__ = "GPL version 2 or (at your option) any later version"
11 __maintainer__ = "Stefan Hajnoczi"
12 __email__ = "stefanha@linux.vnet.ibm.com"
15 from tracetool import out, Arguments
16 import tracetool.vcpu
19 def vcpu_transform_args(args):
20 assert len(args) == 1
21 return Arguments([
22 args,
23 # NOTE: this name must be kept in sync with the one in "tcg_h"
24 # NOTE: Current helper code uses TCGv_env (CPUArchState*)
25 ("TCGv_env", "__tcg_" + args.names()[0]),
29 def generate(events, backend, group):
30 if group == "root":
31 header = "trace-root.h"
32 else:
33 header = "trace.h"
35 out('/* This file is autogenerated by tracetool, do not edit. */',
36 '/* You must include this file after the inclusion of helper.h */',
37 '',
38 '#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
39 '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
40 '',
41 '#include "exec/helper-proto.h"',
42 '#include "%s"' % header,
43 '',
46 for e in events:
47 # just keep one of them
48 if "tcg-exec" not in e.properties:
49 continue
51 out('static inline void %(name_tcg)s(%(args)s)',
52 '{',
53 name_tcg=e.original.api(e.QEMU_TRACE_TCG),
54 args=tracetool.vcpu.transform_args("tcg_h", e.original))
56 if "disable" not in e.properties:
57 args_trans = e.original.event_trans.args
58 args_exec = tracetool.vcpu.transform_args(
59 "tcg_helper_c", e.original.event_exec, "wrapper")
60 if "vcpu" in e.properties:
61 trace_cpu = e.args.names()[0]
62 cond = "trace_event_get_vcpu_state(%(cpu)s,"\
63 " TRACE_%(id)s)"\
64 % dict(
65 cpu=trace_cpu,
66 id=e.original.event_exec.name.upper())
67 else:
68 cond = "true"
70 out(' %(name_trans)s(%(argnames_trans)s);',
71 ' if (%(cond)s) {',
72 ' gen_helper_%(name_exec)s(%(argnames_exec)s);',
73 ' }',
74 name_trans=e.original.event_trans.api(e.QEMU_TRACE),
75 name_exec=e.original.event_exec.api(e.QEMU_TRACE),
76 argnames_trans=", ".join(args_trans.names()),
77 argnames_exec=", ".join(args_exec.names()),
78 cond=cond)
80 out('}')
82 out('',
83 '#endif /* TRACE_%s_GENERATED_TCG_TRACERS_H */' % group.upper())