1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-26 12:55:19 +02:00

add-print-decimal.patch

Signed-off-by: Andy Green <andy@openmoko.com>
This commit is contained in:
Andy Green 2008-11-28 10:16:37 +00:00 committed by Andy Green
parent c7a4e4dc0d
commit 1b043e0fe5
3 changed files with 26 additions and 3 deletions

View File

@ -82,6 +82,7 @@ int puts(const char *string);
void printhex(unsigned char v); void printhex(unsigned char v);
void print8(unsigned char u); void print8(unsigned char u);
void print32(unsigned int u); void print32(unsigned int u);
void printdec(int n);
void hexdump(unsigned char *start, int len); void hexdump(unsigned char *start, int len);
unsigned int _ntohl(unsigned int n); unsigned int _ntohl(unsigned int n);
unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned long crc32(unsigned long crc, const unsigned char *buf,

View File

@ -93,8 +93,9 @@ void bootloader_second_phase(void)
puts(" Found: "); puts(" Found: ");
puts((const char *)hdr->ih_name); puts((const char *)hdr->ih_name);
puts("\n Size: 0x"); puts("\n Size: ");
print32(_ntohl(hdr->ih_size)); printdec(_ntohl(hdr->ih_size) >> 10);
puts(" KiB\n");
if (nand_read_ll(kernel_dram, if (nand_read_ll(kernel_dram,
this_board->kernel_source[kernel]. this_board->kernel_source[kernel].
@ -107,7 +108,7 @@ void bootloader_second_phase(void)
} }
} }
puts("\n Cmdline: "); puts(" Cmdline: ");
puts(p); puts(p);
puts("\n"); puts("\n");

View File

@ -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) --> */ /* 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 * This file is derived from crc32.c from the zlib-1.1.3 distribution