5 p = argparse.ArgumentParser()
7 p.add_argument('-i', '--input', action="store",
8 help="input JSON file name", required = True)
10 p.add_argument('-o', '--output', action="store",
11 help="output C file name", required = True)
13 p.add_argument('-m', '--model', action="append",
14 help="CPU model in format: model[,stepping0]",
19 with open(r.input, 'r') as fp:
20 objects = json.load(fp)
22 c = open(r.output, 'w')
25 #include <perfmon/perfmon_intel.h>
27 static perfmon_intel_pmc_cpu_model_t cpu_model_table[] = {
35 c.write (" {}0x{:02X}, 0x{:02X}, 1{},\n".format("{", m, s, "}"))
38 c.write (" {}0x{:02X}, 0x00, 0{},\n".format("{", m, "}"))
42 static perfmon_intel_pmc_event_t event_table[] = {
46 MSRIndex = obj["MSRIndex"]
50 EventCode = obj["EventCode"]
52 EventName = obj["EventName"].lower()
57 c.write (" .event_code = {}{}{},\n".format("{", EventCode, "}"))
58 c.write (" .umask = {},\n".format(UMask))
59 c.write (" .event_name = \"{}\",\n".format(EventName))
68 PERFMON_REGISTER_INTEL_PMC (cpu_model_table, event_table);