onenand_boot.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * (C) Copyright 2005-2008 Samsung Electronics
  3. * Kyungmin Park <kyungmin.park@samsung.com>
  4. *
  5. * Derived from x-loader
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <version.h>
  27. #include "onenand_ipl.h"
  28. #ifdef CFG_PRINTF
  29. int print_info(void)
  30. {
  31. printf(XLOADER_VERSION);
  32. return 0;
  33. }
  34. #endif
  35. typedef int (init_fnc_t)(void);
  36. init_fnc_t *init_sequence[] = {
  37. board_init, /* basic board dependent setup */
  38. #ifdef CFG_PRINTF
  39. serial_init, /* serial communications setup */
  40. print_info,
  41. #endif
  42. NULL,
  43. };
  44. void start_oneboot(void)
  45. {
  46. init_fnc_t **init_fnc_ptr;
  47. uchar *buf;
  48. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  49. if ((*init_fnc_ptr)() != 0)
  50. hang();
  51. }
  52. buf = (uchar *) CFG_LOAD_ADDR;
  53. if (!onenand_read_block0(buf))
  54. buf += ONENAND_BLOCK_SIZE;
  55. if (buf == (uchar *)CFG_LOAD_ADDR)
  56. hang();
  57. /* go run U-Boot and never return */
  58. printf("Starting OS Bootloader...\n");
  59. ((init_fnc_t *)CFG_LOAD_ADDR)();
  60. /* should never come here */
  61. }
  62. void hang(void)
  63. {
  64. /* if board_hang() returns, hange here */
  65. printf("X-Loader hangs\n");
  66. for (;;);
  67. }