80b336e82784b3b709529de44458f9f36bcb7e41
[kernel/u-boot.git] / recovery / recovery.c
1 /*
2  * Copyright (C) 2010 Samsung Electronics
3  * Minkyu Kang <mk7.kang@samsung.com>
4  */
5
6 #include <common.h>
7 #include <malloc.h>
8 #include "recovery.h"
9 #include "usbd.h"
10 #include "onenand.h"
11
12 #ifdef RECOVERY_DEBUG
13 #define PUTS(s) serial_puts(DEBUG_MARK""s)
14 #else
15 #define PUTS(s)
16 #endif
17
18 typedef int (init_fnc_t)(void);
19
20 static void normal_boot(void)
21 {
22         uchar *buf;
23
24         buf = (uchar *)CONFIG_SYS_BOOT_ADDR;
25
26         board_load_uboot(buf);
27
28         ((init_fnc_t *)CONFIG_SYS_BOOT_ADDR)();
29 }
30
31 static void recovery_boot(void)
32 {
33         PUTS("Recovery Mode\n");
34
35         /* usb download and write image */
36         do_usbd_down();
37
38         /* reboot */
39         /* reset_cpu(0); */
40 }
41
42 void start_recovery_boot(void)
43 {
44         /* armboot_start is defined in the board-specific linker script */
45         mem_malloc_init(_armboot_start - CONFIG_SYS_MALLOC_LEN,
46                         CONFIG_SYS_MALLOC_LEN);
47
48         board_recovery_init();
49
50         onenand_init();
51
52         serial_init();
53         serial_puts("\n");
54
55         if (board_check_condition())
56                 recovery_boot();
57         else
58                 normal_boot();
59
60         /* NOTREACHED - no way out of command loop except booting */
61 }
62
63 /*
64  * origin at lib_arm/eabi_compat.c to support EABI
65  */
66 int raise(int signum)
67 {
68         return 0;
69 }