summaryrefslogtreecommitdiff
path: root/src/console
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2014-11-29 22:05:09 -0800
committerPatrick Georgi <pgeorgi@google.com>2015-03-30 21:42:38 +0200
commit9b0584677f22429b9c14b920d56219c07dab56bd (patch)
tree5fd3d21489bd85991e2ab812c4cb8279a1ae6fd4 /src/console
parent3bc2999cb0b4c0857cd9548aba5abd6bde213282 (diff)
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. [pg: add the printed sequence to the comment, so git grep can find it] BRANCH=none BUG=none TEST=startup code on Urara properly prints CBFS address values which are passed as 64 bit integers. Change-Id: Ie777019cd8d55c53d5e816fbacfe79893c3d64c7 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 8347f914a9cceca017668f8387ba679c2c79e66d Original-Change-Id: I25b8a900b3ba4ec1da3446dcc5f03101d5cdb757 Original-Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/232294 Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/9162 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Aaron Durbin <adurbin@google.com>
Diffstat (limited to 'src/console')
-rw-r--r--src/console/vtxprintf.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c
index b515fb8c7f..2fcefd2831 100644
--- a/src/console/vtxprintf.c
+++ b/src/console/vtxprintf.c
@@ -10,6 +10,10 @@
#define call_tx(x) tx_byte(x, data)
+#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
@@ -33,13 +37,25 @@ static int skip_atoi(const char **s)
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
static int number(void (*tx_byte)(unsigned char byte, void *data),
- unsigned long long num, int base, int size, int precision, int type,
+ unsigned long long inum, int base, int size, int precision, int type,
void *data)
{
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 by printing #^!. */
+ call_tx('#');
+ call_tx('^');
+ call_tx('!');
+ }
+#endif
if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";