Avoid 64bit math on MIPS platforms
Low level 64 bit division and modulo functions are not available for
MIPS platforms, but are required by the printk formatter.
Modify the code to avoid 64 bit math when building for MIPS. In case
the user does print a value exceeding 2^32, send a few junk characters
to the output to indicate a corrupted value printed.
BRANCH=none
BUG=none
TEST=startup code on Urara properly prints CBFS address values which
are passed as 64 bit integers.
Change-Id: I25b8a900b3ba4ec1da3446dcc5f03101d5cdb757
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232294
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
541c0837dd
commit
8347f914a9
1 changed files with 17 additions and 1 deletions
|
|
@ -8,6 +8,10 @@
|
|||
#include <console/console.h>
|
||||
#include <console/vtxprintf.h>
|
||||
|
||||
#if !CONFIG_ARCH_MIPS
|
||||
#define SUPPORT_64BIT_INTS
|
||||
#endif
|
||||
|
||||
/* haha, don't need ctype.c */
|
||||
#define isdigit(c) ((c) >= '0' && (c) <= '9')
|
||||
#define is_digit isdigit
|
||||
|
|
@ -31,12 +35,24 @@ static int skip_atoi(const char **s)
|
|||
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
|
||||
|
||||
static int number(void (*tx_byte)(unsigned char byte),
|
||||
unsigned long long num, int base, int size, int precision, int type)
|
||||
unsigned long long inum, int base, int size, int precision, int type)
|
||||
{
|
||||
char c,sign,tmp[66];
|
||||
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
int i;
|
||||
int count = 0;
|
||||
#ifdef SUPPORT_64BIT_INTS
|
||||
unsigned long long num = inum;
|
||||
#else
|
||||
unsigned long num = (long)inum;
|
||||
|
||||
if (num != inum) {
|
||||
/* Alert user to an incorrect result. */
|
||||
tx_byte('#');
|
||||
tx_byte('^');
|
||||
tx_byte('!');
|
||||
}
|
||||
#endif
|
||||
|
||||
if (type & LARGE)
|
||||
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue