libgenwrap.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * (C) Copyright 2007 Semihalf
  3. *
  4. * Written by: Rafal Jaworowski <raj@semihalf.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. *
  24. *
  25. * This is is a set of wrappers/stubs that allow to use certain routines from
  26. * U-Boot's lib in the standalone app. This way way we can re-use
  27. * existing code e.g. operations on strings and similar.
  28. *
  29. */
  30. #include <common.h>
  31. #include <linux/types.h>
  32. #include <api_public.h>
  33. #include "glue.h"
  34. /*
  35. * printf() and vprintf() are stolen from u-boot/common/console.c
  36. */
  37. int printf (const char *fmt, ...)
  38. {
  39. va_list args;
  40. uint i;
  41. char printbuffer[256];
  42. va_start (args, fmt);
  43. /* For this to work, printbuffer must be larger than
  44. * anything we ever want to print.
  45. */
  46. i = vsprintf (printbuffer, fmt, args);
  47. va_end (args);
  48. /* Print the string */
  49. ub_puts (printbuffer);
  50. return i;
  51. }
  52. int vprintf (const char *fmt, va_list args)
  53. {
  54. uint i;
  55. char printbuffer[256];
  56. /* For this to work, printbuffer must be larger than
  57. * anything we ever want to print.
  58. */
  59. i = vsprintf (printbuffer, fmt, args);
  60. /* Print the string */
  61. ub_puts (printbuffer);
  62. return i;
  63. }
  64. void putc (const char c)
  65. {
  66. ub_putc(c);
  67. }
  68. void __udelay(unsigned long usec)
  69. {
  70. ub_udelay(usec);
  71. }
  72. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  73. {
  74. ub_reset();
  75. return 0;
  76. }
  77. void *malloc (size_t len)
  78. {
  79. return NULL;
  80. }
  81. void hang (void)
  82. {
  83. while (1) ;
  84. }