1/* 2 Copyright (c) 2002, Thomas Kurschel 3 4 5 Part of Radeon driver 6 7 Fast logger - functions to create dump 8*/ 9 10 11#include <stdio.h> 12#include <OS.h> 13 14#include "log_coll.h" 15#include "log_dump.h" 16#include "log_enum.h" 17#include "log_names.h" 18 19system_info sysinfo; 20 21// dump one entry 22static void log_printentry( FILE *logfile, log_entry *entry ) 23{ 24 uint64 time; 25 uint32 min, sec, mill, mic; 26 27 time = entry->tsc / (sysinfo.cpu_clock_speed / 1000000); 28 mic = time % 1000; 29 time /= 1000; 30 mill = time % 1000; 31 time /= 1000; 32 sec = time % 60; 33 time /= 60; 34 min = time; 35 36 fprintf( logfile, "%03ld:%02ld:%03ld.%03ld ", min, sec, mill, mic ); 37 if( entry->what < sizeof( log_names ) / sizeof( log_names[0] ) ) 38 fprintf( logfile, log_names[entry->what] ); 39 else 40 fprintf( logfile, "unknown %ld", (uint32)entry->what ); 41 42 if( entry->num_args > 0 ) { 43 uint32 i; 44 45 fprintf( logfile, " (" ); 46 for( i = 0; i < entry->num_args; ++i ) { 47 if( i > 0 ) 48 fprintf( logfile, ", " ); 49 50 fprintf( logfile, "0x%08lx", entry->args[i] ); 51 } 52 fprintf( logfile, ")" ); 53 } 54 55 fprintf( logfile, "\n" ); 56} 57 58 59// dump entire log 60void log_printall( FILE *logfile, char *buffer, uint32 buffer_len ) 61{ 62 uint32 pos; 63 64 get_system_info( &sysinfo ); 65 66 for( pos = 0; pos < buffer_len; ) { 67 log_entry *entry; 68 69 entry = (log_entry *)(buffer + pos); 70 log_printentry( logfile, entry/*, &tsc*/ ); 71 pos += sizeof( log_entry ) + (entry->num_args - 1) * sizeof( uint32 ); 72 } 73} 74