bsp: a53: added 64bit print support in xil_printf
This patch modifies xil_printf to add support for 64bit pointer value print in case of 64bit mode. It adds support to print 64 bit value for long integer and long hex. It also removes unknown specifier 'D'. Signed-off-by: Kinjal Pravinbhai Patel <patelki@xilinx.com>
This commit is contained in:
parent
607a6324f3
commit
a09427a546
1 changed files with 67 additions and 4 deletions
|
@ -135,6 +135,61 @@ static void outnum( const s32 n, const s32 base, params_t *par)
|
|||
padding( par->left_flag, par);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
/* */
|
||||
/* This routine moves a 64-bit number to the output */
|
||||
/* buffer as directed by the padding and positioning */
|
||||
/* flags. */
|
||||
/* */
|
||||
|
||||
static void outnum1( const s64 n, const s32 base, params_t *par)
|
||||
{
|
||||
charptr cp;
|
||||
s32 negative;
|
||||
s32 i;
|
||||
char8 outbuf[64];
|
||||
const char8 digits[] = "0123456789ABCDEF";
|
||||
u64 num;
|
||||
for(i = 0; i<64; i++) {
|
||||
outbuf[i] = '0';
|
||||
}
|
||||
|
||||
/* Check if number is negative */
|
||||
if ((par->unsigned_flag == 0) && (base == 10) && (n < 0L)) {
|
||||
negative = 1;
|
||||
num =(-(n));
|
||||
}
|
||||
else{
|
||||
num = (n);
|
||||
negative = 0;
|
||||
}
|
||||
|
||||
/* Build number (backwards) in outbuf */
|
||||
i = 0;
|
||||
do {
|
||||
outbuf[i] = digits[(num % base)];
|
||||
i++;
|
||||
num /= base;
|
||||
} while (num > 0);
|
||||
|
||||
if (negative != 0) {
|
||||
outbuf[i] = '-';
|
||||
i++;
|
||||
}
|
||||
|
||||
outbuf[i] = 0;
|
||||
i--;
|
||||
|
||||
/* Move the converted number to the buffer and */
|
||||
/* add in the padding where needed. */
|
||||
par->len = (s32)strlen(outbuf);
|
||||
padding( !(par->left_flag), par);
|
||||
while (&outbuf[i] >= outbuf) {
|
||||
outbyte( outbuf[i] );
|
||||
i--;
|
||||
}
|
||||
padding( par->left_flag, par);
|
||||
}
|
||||
/*---------------------------------------------------*/
|
||||
/* */
|
||||
/* This routine gets a number from the format */
|
||||
|
@ -270,8 +325,8 @@ void xil_printf( const char8 *ctrl1, ...)
|
|||
/* fall through */
|
||||
case 'i':
|
||||
case 'd':
|
||||
if ((long_flag != 0) || (ch == 'D')) {
|
||||
outnum( va_arg(argp, s32), 10L, &par);
|
||||
if (long_flag != 0){
|
||||
outnum1((s64)va_arg(argp, s64), 10L, &par);
|
||||
}
|
||||
else {
|
||||
outnum( va_arg(argp, s32), 10L, &par);
|
||||
|
@ -279,10 +334,18 @@ void xil_printf( const char8 *ctrl1, ...)
|
|||
Check = 1;
|
||||
break;
|
||||
case 'p':
|
||||
case 'X':
|
||||
par.unsigned_flag = 1;
|
||||
outnum1((s64)va_arg(argp, s64), 16L, &par);
|
||||
Check = 1;
|
||||
break;
|
||||
case 'x':
|
||||
par.unsigned_flag = 1;
|
||||
outnum((s32)va_arg(argp, s32), 16L, &par);
|
||||
if (long_flag != 0) {
|
||||
outnum1((s64)va_arg(argp, s64), 16L, &par);
|
||||
}
|
||||
else {
|
||||
outnum((s32)va_arg(argp, s32), 16L, &par);
|
||||
}
|
||||
Check = 1;
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue