00001 00011 #include <stdio.h> 00012 #include <string.h> 00013 #include "op_events.h" 00014 #include "op_list.h" 00015 #include "op_cpu_type.h" 00016 #include "op_xml_out.h" 00017 00018 static op_cpu cpu_type; 00019 #define MAX_BUFFER 16384 00020 static char buffer[MAX_BUFFER]; 00021 00022 void open_xml_events(char const * title, char const * doc, op_cpu the_cpu_type) 00023 { 00024 char const * schema_version = "1.1"; 00025 00026 buffer[0] = '\0'; 00027 cpu_type = the_cpu_type; 00028 open_xml_element(HELP_EVENTS, 1, buffer, MAX_BUFFER); 00029 init_xml_str_attr(SCHEMA_VERSION, schema_version, buffer, MAX_BUFFER); 00030 close_xml_element(NONE, 1, buffer, MAX_BUFFER); 00031 open_xml_element(HELP_HEADER, 1, buffer, MAX_BUFFER); 00032 init_xml_str_attr(HELP_TITLE, title, buffer, MAX_BUFFER); 00033 init_xml_str_attr(HELP_DOC, doc, buffer, MAX_BUFFER); 00034 close_xml_element(NONE, 0, buffer, MAX_BUFFER); 00035 printf("%s", buffer); 00036 } 00037 00038 void close_xml_events(void) 00039 { 00040 buffer[0] = '\0'; 00041 close_xml_element(HELP_EVENTS, 0, buffer, MAX_BUFFER); 00042 printf("%s", buffer); 00043 } 00044 00045 static void xml_do_arch_specific_event_help(struct op_event const *event, 00046 char *buffer, size_t size) 00047 { 00048 switch (cpu_type) { 00049 case CPU_PPC64_CELL: 00050 init_xml_int_attr(HELP_EVENT_GROUP, event->val / 100, buffer, 00051 size); 00052 break; 00053 default: 00054 break; 00055 } 00056 } 00057 00058 00059 void xml_help_for_event(struct op_event const * event) 00060 { 00061 uint i; 00062 int has_nested = strcmp(event->unit->name, "zero"); 00063 00064 buffer[0] = '\0'; 00065 open_xml_element(HELP_EVENT, 1, buffer, MAX_BUFFER); 00066 init_xml_str_attr(HELP_EVENT_NAME, event->name, buffer, MAX_BUFFER); 00067 xml_do_arch_specific_event_help(event, buffer, MAX_BUFFER); 00068 init_xml_str_attr(HELP_EVENT_DESC, event->desc, buffer, MAX_BUFFER); 00069 00070 init_xml_int_attr(HELP_COUNTER_MASK, event->counter_mask, buffer, 00071 MAX_BUFFER); 00072 if (event->ext) 00073 init_xml_str_attr(HELP_EXT, event->ext, buffer, MAX_BUFFER); 00074 init_xml_int_attr(HELP_MIN_COUNT, event->min_count, 00075 buffer, MAX_BUFFER); 00076 00077 if (has_nested) { 00078 char um_type[10]; 00079 close_xml_element(NONE, 1, buffer, MAX_BUFFER); 00080 open_xml_element(HELP_UNIT_MASKS, 1, buffer, MAX_BUFFER); 00081 init_xml_int_attr(HELP_DEFAULT_MASK, event->unit->default_mask, 00082 buffer, MAX_BUFFER); 00083 switch (event->unit->unit_type_mask){ 00084 case utm_bitmask: 00085 strncpy(um_type, "bitmask", sizeof(um_type)); 00086 break; 00087 case utm_exclusive: 00088 strncpy(um_type, "exclusive", sizeof(um_type)); 00089 break; 00090 case utm_mandatory: 00091 strncpy(um_type, "mandatory", sizeof(um_type)); 00092 break; 00093 } 00094 init_xml_str_attr(HELP_UNIT_MASKS_CATEGORY, um_type, buffer, MAX_BUFFER); 00095 close_xml_element(NONE, 1, buffer, MAX_BUFFER); 00096 for (i = 0; i < event->unit->num; i++) { 00097 open_xml_element(HELP_UNIT_MASK, 1, buffer, MAX_BUFFER); 00098 init_xml_int_attr(HELP_UNIT_MASK_VALUE, 00099 event->unit->um[i].value, 00100 buffer, MAX_BUFFER); 00101 init_xml_str_attr(HELP_UNIT_MASK_DESC, 00102 event->unit->um[i].desc, 00103 buffer, MAX_BUFFER); 00104 if (event->unit->um[i].extra) 00105 init_xml_int_attr(HELP_UNIT_EXTRA_VALUE, 00106 event->unit->um[i].extra, 00107 buffer, MAX_BUFFER); 00108 close_xml_element(NONE, 0, buffer, MAX_BUFFER); 00109 } 00110 close_xml_element(HELP_UNIT_MASKS, 0, buffer, MAX_BUFFER); 00111 } 00112 close_xml_element(has_nested ? HELP_EVENT : NONE, has_nested, 00113 buffer, MAX_BUFFER); 00114 printf("%s", buffer); 00115 } 00116