kernels/linux-2.4.0/arch/ia64/kernel/palinfo.c
/*
 * Take a 64bit vector and produces a string such that
 * if bit n is set then register n is present. The function
 * takes into account consecutive registers and prints out ranges.
 *
 * Input:
 *	- a pointer to a buffer to hold the string
 * 	- a 64-bit vector
 * Ouput:
 *	- a pointer to the end of the buffer
 *
 */
Take a 64bit vector and produces a string such that
if bit n is set then register n is present. The function
takes into account consecutive registers and prints out ranges.

- a pointer to a buffer to hold the string
- a 64-bit vector
Ouput:
- a pointer to the end of the buffer
Take a 64bit vector and produces a string such that if bit n is set then register n is present . The function takes into account consecutive registers and prints out ranges . - a pointer to a buffer to hold the string - a 64 - bit vector Ouput : - a pointer to the end of the buffer
static char *
bitregister_process(char *p, u64 *reg_info, int max)
{
	int i, begin, skip = 0;
	u64 value = reg_info[0];
	value >>= i = begin = ffs(value) - 1;
	for(; i < max; i++ ) {
		if (i != 0 && (i%64) == 0) value = *++reg_info;
		if ((value & 0x1) == 0 && skip == 0) {
			if (begin  <= i - 2) 
				p += sprintf(p, "%d-%d ", begin, i-1);
			else
				p += sprintf(p, "%d ", i-1);
			skip  = 1;
			begin = -1;
		} else if ((value & 0x1) && skip == 1) {
			skip = 0;
			begin = i;
		}
		value >>=1;
	}
	if (begin > -1) {
		if (begin < 127) 
			p += sprintf(p, "%d-127", begin);
		else
			p += sprintf(p, "127");
	}
	return p;
}
static char * bitregister_process ( char * p , u64 * reg_info , int max ) { int i , begin , skip = 0 ; u64 value = reg_info [ 0 ] ; value >>= i = begin = ffs ( value ) - 1 ; for ( ; i < max ; i ++ ) { if ( i != 0 && ( i % 64 ) == 0 ) value = * ++ reg_info ; if ( ( value & 0x1 ) == 0 && skip == 0 ) { if ( begin <= i - 2 ) p += sprintf ( p , " " , begin , i - 1 ) ; else p += sprintf ( p , " " , i - 1 ) ; skip = 1 ; begin = -1 ; } else if ( ( value & 0x1 ) && skip == 1 ) { skip = 0 ; begin = i ; } value >>= 1 ; } if ( begin > -1 ) { if ( begin < 127 ) p += sprintf ( p , " " , begin ) ; else p += sprintf ( p , " " ) ; } return p ; }
Take a 64bit vector and produces a string such that
 if bit n is set then register n is present.
Take a 64bit vector and produces a string such that if bit n is set then register n is present .