Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007 Semihalf |
| 3 | * |
| 4 | * Written by: Rafal Jaworowski <raj@semihalf.com> |
| 5 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 7 | * |
| 8 | * This is is a set of wrappers/stubs that allow to use certain routines from |
Peter Tyser | 685b7f5 | 2010-04-12 22:28:05 -0500 | [diff] [blame] | 9 | * U-Boot's lib in the standalone app. This way way we can re-use |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 10 | * existing code e.g. operations on strings and similar. |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <api_public.h> |
| 16 | |
| 17 | #include "glue.h" |
| 18 | |
| 19 | /* |
| 20 | * printf() and vprintf() are stolen from u-boot/common/console.c |
| 21 | */ |
Wolfgang Denk | 318ef5c | 2010-06-20 17:14:14 +0200 | [diff] [blame] | 22 | int printf (const char *fmt, ...) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 23 | { |
| 24 | va_list args; |
| 25 | uint i; |
| 26 | char printbuffer[256]; |
| 27 | |
| 28 | va_start (args, fmt); |
| 29 | |
| 30 | /* For this to work, printbuffer must be larger than |
| 31 | * anything we ever want to print. |
| 32 | */ |
| 33 | i = vsprintf (printbuffer, fmt, args); |
| 34 | va_end (args); |
| 35 | |
| 36 | /* Print the string */ |
| 37 | ub_puts (printbuffer); |
Wolfgang Denk | 318ef5c | 2010-06-20 17:14:14 +0200 | [diff] [blame] | 38 | return i; |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 39 | } |
| 40 | |
Wolfgang Denk | 318ef5c | 2010-06-20 17:14:14 +0200 | [diff] [blame] | 41 | int vprintf (const char *fmt, va_list args) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 42 | { |
| 43 | uint i; |
| 44 | char printbuffer[256]; |
| 45 | |
| 46 | /* For this to work, printbuffer must be larger than |
| 47 | * anything we ever want to print. |
| 48 | */ |
| 49 | i = vsprintf (printbuffer, fmt, args); |
| 50 | |
| 51 | /* Print the string */ |
| 52 | ub_puts (printbuffer); |
Wolfgang Denk | 318ef5c | 2010-06-20 17:14:14 +0200 | [diff] [blame] | 53 | return i; |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | void putc (const char c) |
| 57 | { |
| 58 | ub_putc(c); |
| 59 | } |
| 60 | |
Ingo van Lil | f0f778a | 2009-11-24 14:09:21 +0100 | [diff] [blame] | 61 | void __udelay(unsigned long usec) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 62 | { |
| 63 | ub_udelay(usec); |
| 64 | } |
| 65 | |
Mike Frysinger | 1f0a7e3 | 2010-12-19 17:16:53 -0500 | [diff] [blame] | 66 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 67 | { |
| 68 | ub_reset(); |
Mike Frysinger | 1f0a7e3 | 2010-12-19 17:16:53 -0500 | [diff] [blame] | 69 | return 0; |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 70 | } |
| 71 | |
Rafal Jaworowski | 35e4e8d | 2008-01-29 17:00:34 +0100 | [diff] [blame] | 72 | void *malloc (size_t len) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 73 | { |
| 74 | return NULL; |
| 75 | } |
Rafal Jaworowski | 35e4e8d | 2008-01-29 17:00:34 +0100 | [diff] [blame] | 76 | |
| 77 | void hang (void) |
| 78 | { |
| 79 | while (1) ; |
| 80 | } |