libgenwrap.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * (C) Copyright 2007 Semihalf
  3. *
  4. * Written by: Rafal Jaworowski <raj@semihalf.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. *
  8. * This is is a set of wrappers/stubs that allow to use certain routines from
  9. * U-Boot's lib in the standalone app. This way way we can re-use
  10. * existing code e.g. operations on strings and similar.
  11. */
  12. #include <common.h>
  13. #include <linux/types.h>
  14. #include <api_public.h>
  15. #include "glue.h"
  16. /*
  17. * printf() and vprintf() are stolen from u-boot/common/console.c
  18. */
  19. int printf (const char *fmt, ...)
  20. {
  21. va_list args;
  22. uint i;
  23. char printbuffer[256];
  24. va_start (args, fmt);
  25. /* For this to work, printbuffer must be larger than
  26. * anything we ever want to print.
  27. */
  28. i = vsprintf (printbuffer, fmt, args);
  29. va_end (args);
  30. /* Print the string */
  31. ub_puts (printbuffer);
  32. return i;
  33. }
  34. int vprintf (const char *fmt, va_list args)
  35. {
  36. uint i;
  37. char printbuffer[256];
  38. /* For this to work, printbuffer must be larger than
  39. * anything we ever want to print.
  40. */
  41. i = vsprintf (printbuffer, fmt, args);
  42. /* Print the string */
  43. ub_puts (printbuffer);
  44. return i;
  45. }
  46. void putc (const char c)
  47. {
  48. ub_putc(c);
  49. }
  50. void __udelay(unsigned long usec)
  51. {
  52. ub_udelay(usec);
  53. }
  54. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  55. {
  56. ub_reset();
  57. return 0;
  58. }
  59. void *malloc (size_t len)
  60. {
  61. return NULL;
  62. }
  63. void hang (void)
  64. {
  65. while (1) ;
  66. }