blob: 5644d589e7609c0bea09239f89692ca15a391b57 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/*
2 * U-boot - boot.c - misc boot helper functions
3 *
4 * Copyright (c) 2005-2008 Analog Devices Inc.
5 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
9 * Licensed under the GPL-2 or later.
10 */
11
12#include <common.h>
13#include <command.h>
14#include <image.h>
15#include <asm/blackfin.h>
16
17#ifdef SHARED_RESOURCES
18extern void swap_to(int device_id);
19#endif
20
21#ifdef CONFIG_VIDEO
22extern void video_stop(void);
23#endif
24
25static char *make_command_line(void)
26{
27 char *dest = (char *)CONFIG_LINUX_CMDLINE_ADDR;
28 char *bootargs = getenv("bootargs");
29
30 if (bootargs == NULL)
31 return NULL;
32
33 strncpy(dest, bootargs, CONFIG_LINUX_CMDLINE_SIZE);
34 dest[CONFIG_LINUX_CMDLINE_SIZE - 1] = 0;
35 return dest;
36}
37
38extern ulong bfin_poweron_retx;
39
40int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
41{
42 int (*appl) (char *cmdline);
43 char *cmdline;
44
45 if (flag & BOOTM_STATE_OS_PREP)
46 return 0;
47 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
48 return 1;
49
50#ifdef SHARED_RESOURCES
51 swap_to(FLASH);
52#endif
53
54#ifdef CONFIG_VIDEO
55 /* maybe this should be standardized and moved to bootm ... */
56 video_stop();
57#endif
58
59 appl = (int (*)(char *))images->ep;
60
61 printf("Starting Kernel at = %p\n", appl);
62 cmdline = make_command_line();
63 icache_disable();
64 dcache_disable();
65 asm __volatile__(
66 "RETX = %[retx];"
67 "CALL (%0);"
68 :
69 : "p"(appl), "q0"(cmdline), [retx] "d"(bfin_poweron_retx)
70 );
71 /* does not return */
72
73 return 1;
74}