aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/boot/Makefile2
-rw-r--r--arch/powerpc/boot/stdlib.c45
-rw-r--r--arch/powerpc/boot/stdlib.h6
3 files changed, 52 insertions, 1 deletions
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index fd16577a40d5..cffef147e042 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -45,7 +45,7 @@ src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
45 ns16550.c serial.c simple_alloc.c div64.S util.S \ 45 ns16550.c serial.c simple_alloc.c div64.S util.S \
46 gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ 46 gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
47 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \ 47 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
48 cpm-serial.c 48 cpm-serial.c stdlib.c
49src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \ 49src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
50 cuboot-ebony.c treeboot-ebony.c prpmc2800.c \ 50 cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
51 ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \ 51 ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \
diff --git a/arch/powerpc/boot/stdlib.c b/arch/powerpc/boot/stdlib.c
new file mode 100644
index 000000000000..e00d58c29eea
--- /dev/null
+++ b/arch/powerpc/boot/stdlib.c
@@ -0,0 +1,45 @@
1/*
2 * stdlib functions
3 *
4 * Author: Scott Wood <scottwood@freescale.com>
5 *
6 * Copyright (c) 2007 Freescale Semiconductor, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13#include "stdlib.h"
14
15/* Not currently supported: leading whitespace, sign, 0x prefix, zero base */
16unsigned long long int strtoull(const char *ptr, char **end, int base)
17{
18 unsigned long long ret = 0;
19
20 if (base > 36)
21 goto out;
22
23 while (*ptr) {
24 int digit;
25
26 if (*ptr >= '0' && *ptr <= '9' && *ptr < '0' + base)
27 digit = *ptr - '0';
28 else if (*ptr >= 'A' && *ptr < 'A' + base - 10)
29 digit = *ptr - 'A' + 10;
30 else if (*ptr >= 'a' && *ptr < 'a' + base - 10)
31 digit = *ptr - 'a' + 10;
32 else
33 break;
34
35 ret *= base;
36 ret += digit;
37 ptr++;
38 }
39
40out:
41 if (end)
42 *end = (char *)ptr;
43
44 return ret;
45}
diff --git a/arch/powerpc/boot/stdlib.h b/arch/powerpc/boot/stdlib.h
new file mode 100644
index 000000000000..1bf01ac73aba
--- /dev/null
+++ b/arch/powerpc/boot/stdlib.h
@@ -0,0 +1,6 @@
1#ifndef _PPC_BOOT_STDLIB_H_
2#define _PPC_BOOT_STDLIB_H_
3
4unsigned long long int strtoull(const char *ptr, char **end, int base);
5
6#endif