1/** 2 * @file op_xml_events.c 3 * routines for generating event files in XML 4 * 5 * @remark Copyright 2008 OProfile authors 6 * @remark Read the file COPYING 7 * 8 * @author Dave Nomura 9 */ 10 11#include <stdio.h> 12#include <string.h> 13#include "op_events.h" 14#include "op_list.h" 15#include "op_cpu_type.h" 16#include "op_xml_out.h" 17 18static op_cpu cpu_type; 19#define MAX_BUFFER 4096 20void open_xml_events(char const * title, char const * doc, op_cpu the_cpu_type) 21{ 22 char const * schema_version = "1.0"; 23 char buffer[MAX_BUFFER]; 24 25 buffer[0] = '\0'; 26 cpu_type = the_cpu_type; 27 open_xml_element(HELP_EVENTS, 0, buffer); 28 open_xml_element(HELP_HEADER, 1, buffer); 29 init_xml_str_attr(HELP_TITLE, title, buffer); 30 init_xml_str_attr(SCHEMA_VERSION, schema_version, buffer); 31 init_xml_str_attr(HELP_DOC, doc, buffer); 32 close_xml_element(NONE, 0, buffer); 33 printf("%s", buffer); 34} 35 36void close_xml_events(void) 37{ 38 char buffer[MAX_BUFFER]; 39 40 buffer[0] = '\0'; 41 close_xml_element(HELP_EVENTS, 0, buffer); 42 printf("%s", buffer); 43} 44 45static void xml_do_arch_specific_event_help(struct op_event const * event, 46 char * buffer) 47{ 48 switch (cpu_type) { 49 case CPU_PPC64_CELL: 50 init_xml_int_attr(HELP_EVENT_GROUP, event->val / 100, buffer); 51 break; 52 default: 53 break; 54 } 55} 56 57 58void xml_help_for_event(struct op_event const * event) 59{ 60 uint i; 61 int nr_counters; 62 int has_nested = strcmp(event->unit->name, "zero"); 63 char buffer[MAX_BUFFER]; 64 65 buffer[0] = '\0'; 66 open_xml_element(HELP_EVENT, 1, buffer); 67 init_xml_str_attr(HELP_EVENT_NAME, event->name, buffer); 68 xml_do_arch_specific_event_help(event, buffer); 69 init_xml_str_attr(HELP_EVENT_DESC, event->desc, buffer); 70 71 nr_counters = op_get_nr_counters(cpu_type); 72 init_xml_int_attr(HELP_COUNTER_MASK, event->counter_mask, buffer); 73 init_xml_int_attr(HELP_MIN_COUNT, event->min_count, buffer); 74 75 if (has_nested) { 76 close_xml_element(NONE, 1, buffer); 77 open_xml_element(HELP_UNIT_MASKS, 1, buffer); 78 init_xml_int_attr(HELP_DEFAULT_MASK, event->unit->default_mask, buffer); 79 close_xml_element(NONE, 1, buffer); 80 for (i = 0; i < event->unit->num; i++) { 81 open_xml_element(HELP_UNIT_MASK, 1, buffer); 82 init_xml_int_attr(HELP_UNIT_MASK_VALUE, 83 event->unit->um[i].value, buffer); 84 init_xml_str_attr(HELP_UNIT_MASK_DESC, 85 event->unit->um[i].desc, buffer); 86 close_xml_element(NONE, 0, buffer); 87 } 88 close_xml_element(HELP_UNIT_MASKS, 0, buffer); 89 } 90 close_xml_element(has_nested ? HELP_EVENT : NONE, has_nested, buffer); 91 printf("%s", buffer); 92} 93 94