u-boot/examples/api/libgenwrap.c
Stefan Roese 7d9cde1031 lib/tiny-printf.c: Add tiny printf function for space limited environments
This patch adds a small printf() version that supports all basic formats.
Its intented to be used in U-Boot SPL versions on platforms with very
limited internal RAM sizes.

To enable it, just define CONFIG_USE_TINY_PRINTF in your defconfig. This
will result in the SPL using this tiny function and the main U-Boot
still using the full-blown printf() function.

This code was copied from:
http://www.sparetimelabs.com/printfrevisited
With mostly only coding style related changes so that its checkpatch
clean.

The size reduction is about 2.5KiB. Here a comparison for the db-mv784mp-gp
(Marvell AXP) SPL:

Without this patch:
  58963   18536    1928   79427   13643 ./spl/u-boot-spl

With this patch:
  56542   18536    1956   77034   12cea ./spl/u-boot-spl

Note:
To make it possible to compile tiny-printf.c instead of vsprintf.c when
CONFIG_USE_TINY_PRINTF is defined, the functions printf() and vprintf() are
moved from common/console.c into vsprintf.c in this patch.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
2015-11-23 10:56:07 -05:00

48 lines
748 B
C

/*
* (C) Copyright 2007 Semihalf
*
* Written by: Rafal Jaworowski <raj@semihalf.com>
*
* SPDX-License-Identifier: GPL-2.0+
*
* This is is a set of wrappers/stubs that allow to use certain routines from
* U-Boot's lib in the standalone app. This way way we can re-use
* existing code e.g. operations on strings and similar.
*/
#include <common.h>
#include <linux/types.h>
#include <api_public.h>
#include "glue.h"
void putc(const char c)
{
ub_putc(c);
}
void puts(const char *s)
{
ub_puts(s);
}
void __udelay(unsigned long usec)
{
ub_udelay(usec);
}
int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ub_reset();
return 0;
}
void *malloc (size_t len)
{
return NULL;
}
void hang (void)
{
while (1) ;
}