1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2008 - 2013 Tensilica Inc.
* (C) Copyright 2014 Cadence Design Systems Inc.
*/
#include <common.h>
#include <bootstage.h>
#include <command.h>
#include <cpu_func.h>
#include <env.h>
#include <u-boot/zlib.h>
#include <asm/byteorder.h>
#include <asm/addrspace.h>
#include <asm/bootparam.h>
#include <asm/cache.h>
#include <image.h>
DECLARE_GLOBAL_DATA_PTR;
/*
* Setup boot-parameters.
*/
static struct bp_tag *setup_first_tag(struct bp_tag *params)
{
params->id = BP_TAG_FIRST;
params->size = sizeof(long);
*(unsigned long *)¶ms->data = BP_VERSION;
return bp_tag_next(params);
}
static struct bp_tag *setup_last_tag(struct bp_tag *params)
{
params->id = BP_TAG_LAST;
params->size = 0;
return bp_tag_next(params);
}
static struct bp_tag *setup_memory_tag(struct bp_tag *params)
{
struct meminfo *mem;
params->id = BP_TAG_MEMORY;
params->size = sizeof(struct meminfo);
mem = (struct meminfo *)params->data;
mem->type = MEMORY_TYPE_CONVENTIONAL;
mem->start = PHYSADDR(gd->ram_base);
mem->end = PHYSADDR(gd->ram_base + gd->ram_size);
printf(" MEMORY: tag:0x%04x, type:0X%lx, start:0X%lx, end:0X%lx\n",
BP_TAG_MEMORY, mem->type, mem->start, mem->end);
return bp_tag_next(params);
}
static struct bp_tag *setup_commandline_tag(struct bp_tag *params,
char *cmdline)
{
int len;
if (!cmdline)
return params;
len = strlen(cmdline);
params->id = BP_TAG_COMMAND_LINE;
params->size = (len + 3) & -4;
strcpy((char *)params->data, cmdline);
printf(" COMMAND_LINE: tag:0x%04x, size:%u, data:'%s'\n",
BP_TAG_COMMAND_LINE, params->size, cmdline);
return bp_tag_next(params);
}
static struct bp_tag *setup_ramdisk_tag(struct bp_tag *params,
unsigned long rd_start,
unsigned long rd_end)
{
struct meminfo *mem;
if (rd_start == rd_end)
return params;
/* Add a single banked memory */
params->id = BP_TAG_INITRD;
params->size = sizeof(struct meminfo);
mem = (struct meminfo *)params->data;
mem->type = MEMORY_TYPE_CONVENTIONAL;
mem->start = PHYSADDR(rd_start);
mem->end = PHYSADDR(rd_end);
printf(" INITRD: tag:0x%x, type:0X%04lx, start:0X%lx, end:0X%lx\n",
BP_TAG_INITRD, mem->type, mem->start, mem->end);
return bp_tag_next(params);
}
static struct bp_tag *setup_serial_tag(struct bp_tag *params)
{
params->id = BP_TAG_SERIAL_BAUDRATE;
params->size = sizeof(unsigned long);
params->data[0] = gd->baudrate;
printf(" SERIAL_BAUDRATE: tag:0x%04x, size:%u, baudrate:%lu\n",
BP_TAG_SERIAL_BAUDRATE, params->size, params->data[0]);
return bp_tag_next(params);
}
#ifdef CONFIG_OF_LIBFDT
static struct bp_tag *setup_fdt_tag(struct bp_tag *params, void *fdt_start)
{
params->id = BP_TAG_FDT;
params->size = sizeof(unsigned long);
params->data[0] = (unsigned long)fdt_start;
printf(" FDT: tag:0x%04x, size:%u, start:0x%lx\n",
BP_TAG_FDT, params->size, params->data[0]);
return bp_tag_next(params);
}
#endif
/*
* Boot Linux.
*/
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
{
struct bp_tag *params, *params_start;
ulong initrd_start, initrd_end;
char *commandline = env_get("bootargs");
if (!(flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)))
return 0;
show_boot_progress(15);
if (images->rd_start) {
initrd_start = images->rd_start;
initrd_end = images->rd_end;
} else {
initrd_start = 0;
initrd_end = 0;
}
params_start = (struct bp_tag *)gd->bd->bi_boot_params;
params = params_start;
params = setup_first_tag(params);
params = setup_memory_tag(params);
params = setup_commandline_tag(params, commandline);
params = setup_serial_tag(params);
if (initrd_start)
params = setup_ramdisk_tag(params, initrd_start, initrd_end);
#ifdef CONFIG_OF_LIBFDT
if (images->ft_addr)
params = setup_fdt_tag(params, images->ft_addr);
#endif
printf("\n");
params = setup_last_tag(params);
show_boot_progress(15);
printf("Transferring Control to Linux @0x%08lx ...\n\n",
(ulong)images->ep);
flush_dcache_range((unsigned long)params_start, (unsigned long)params);
if (flag & BOOTM_STATE_OS_FAKE_GO)
return 0;
/*
* _start() in vmlinux expects boot params in register a2.
* NOTE:
* Disable/delete your u-boot breakpoints before stepping into linux.
*/
asm volatile ("mov a2, %0\n\t"
"jx %1\n\t"
: : "a" (params_start), "a" (images->ep)
: "a2");
/* Does not return */
return 1;
}
|