/*
* Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
*
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
/**
* Print debug message
*
* @v fmt Format string
* @v ... Arguments
*/
int saved_usage;
/* Mark console as in use for debugging messages */
/* Print message */
/* Restore console usage */
}
/**
* Pause until a key is pressed
*
*/
void dbg_pause ( void ) {
dbg_printf ( "\nPress a key..." );
getchar();
dbg_printf ( "\r \r" );
}
/**
* Indicate more data to follow and pause until a key is pressed
*
*/
void dbg_more ( void ) {
dbg_printf ( "---more---" );
getchar();
dbg_printf ( "\r \r" );
}
/**
* Print row of a hex dump with specified display address
*
* @v dispaddr Display address
* @v data Data to print
* @v len Length of data
* @v offset Starting offset within data
*/
unsigned int i;
if ( i >= len ) {
dbg_printf ( " " );
continue;
}
dbg_printf ( "%c%02x",
}
dbg_printf ( " : " );
if ( i >= len ) {
dbg_printf ( " " );
continue;
}
byte = '.';
}
dbg_printf ( "\n" );
}
/**
* Print hex dump with specified display address
*
* @v dispaddr Display address
* @v data Data to print
* @v len Length of data
*/
unsigned long len ) {
unsigned int offset;
}
}
/**
* Maximum number of separately coloured message streams
*
* Six is the realistic maximum; there are 8 basic ANSI colours, one
* of which will be the terminal default and one of which will be
* invisible on the terminal because it matches the background colour.
*/
/** A colour assigned to an autocolourised debug message stream */
struct autocolour {
/** Message stream ID */
unsigned long stream;
/** Last recorded usage */
unsigned long last_used;
};
/**
* Choose colour index for debug autocolourisation
*
* @v stream Message stream ID
* @ret colour Colour ID
*/
static unsigned long use;
unsigned int i;
unsigned int oldest;
unsigned int oldest_last_used;
/* Increment usage iteration counter */
use++;
/* Scan through list for a currently assigned colour */
return i;
}
}
/* No colour found; evict the oldest from the list */
oldest = 0;
oldest = i;
}
}
return oldest;
}
/**
* Select automatic colour for debug messages
*
* @v stream Message stream ID
*/
dbg_printf ( "\033[%dm",
}
/**
* Revert to normal colour
*
*/
void dbg_decolourise ( void ) {
dbg_printf ( "\033[0m" );
}