From 1b043e0fe5768687f5277f38e174c3097e066300 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 28 Nov 2008 10:16:37 +0000 Subject: [PATCH] add-print-decimal.patch Signed-off-by: Andy Green --- qiboot/include/qi.h | 1 + qiboot/src/phase2.c | 7 ++++--- qiboot/src/utils.c | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/qiboot/include/qi.h b/qiboot/include/qi.h index 17fafe7..ea0382b 100644 --- a/qiboot/include/qi.h +++ b/qiboot/include/qi.h @@ -82,6 +82,7 @@ int puts(const char *string); void printhex(unsigned char v); void print8(unsigned char u); void print32(unsigned int u); +void printdec(int n); void hexdump(unsigned char *start, int len); unsigned int _ntohl(unsigned int n); unsigned long crc32(unsigned long crc, const unsigned char *buf, diff --git a/qiboot/src/phase2.c b/qiboot/src/phase2.c index 826e90e..b2ad6a9 100644 --- a/qiboot/src/phase2.c +++ b/qiboot/src/phase2.c @@ -93,8 +93,9 @@ void bootloader_second_phase(void) puts(" Found: "); puts((const char *)hdr->ih_name); - puts("\n Size: 0x"); - print32(_ntohl(hdr->ih_size)); + puts("\n Size: "); + printdec(_ntohl(hdr->ih_size) >> 10); + puts(" KiB\n"); if (nand_read_ll(kernel_dram, this_board->kernel_source[kernel]. @@ -107,7 +108,7 @@ void bootloader_second_phase(void) } } - puts("\n Cmdline: "); + puts(" Cmdline: "); puts(p); puts("\n"); diff --git a/qiboot/src/utils.c b/qiboot/src/utils.c index 5f183bc..11b1675 100644 --- a/qiboot/src/utils.c +++ b/qiboot/src/utils.c @@ -102,6 +102,27 @@ void hexdump(unsigned char *start, int len) } } +void printdec(int n) +{ + int d = 1 * 1000 * 1000 * 1000; + int flag = 0; + + if (n < 0) { + this_board->putc('-'); + n = -n; + } + + while (d) { + int r = n / d; + if (r || flag || (d == 1)) { + this_board->putc('0' + r); + flag = 1; + } + n -= r * d; + d = d / 10; + } +} + /* original copyright notice for this crc code (it is from U-Boot) --> */ /* * This file is derived from crc32.c from the zlib-1.1.3 distribution