2008-08-13 02:45:55 +03:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2008 Openmoko, Inc.
|
|
|
|
* Author: Andy Green <andy@openmoko.org>
|
|
|
|
*
|
|
|
|
* Parse the U-Boot header and Boot Linux
|
|
|
|
* based on various code from U-Boot
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2008-11-28 12:16:35 +02:00
|
|
|
#include <qi.h>
|
2008-08-13 02:42:35 +03:00
|
|
|
#include <neo_gta02.h>
|
|
|
|
#include "blink_led.h"
|
|
|
|
#include <string.h>
|
|
|
|
#define __ARM__
|
|
|
|
#include <image.h>
|
|
|
|
#include <setup.h>
|
2008-11-28 12:16:37 +02:00
|
|
|
#include <ext2.h>
|
|
|
|
|
2009-01-09 06:32:51 +02:00
|
|
|
|
|
|
|
typedef void (*the_kernel_fn)(int zero, int arch, uint params);
|
|
|
|
|
2008-11-28 12:16:37 +02:00
|
|
|
unsigned long partition_offset_blocks = 0;
|
|
|
|
unsigned long partition_length_blocks = 0;
|
|
|
|
|
|
|
|
struct kernel_source const * this_kernel = 0;
|
2008-08-13 02:42:35 +03:00
|
|
|
|
2009-01-09 06:32:51 +02:00
|
|
|
static const int INITRD_OFFSET = (8 * 1024 * 1024);
|
2008-11-28 12:16:41 +02:00
|
|
|
|
2008-12-01 03:26:06 +02:00
|
|
|
|
2008-11-28 12:16:40 +02:00
|
|
|
int raise(int n)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-09 06:32:51 +02:00
|
|
|
static void indicate(enum ui_indication ui_indication)
|
2008-12-01 03:26:06 +02:00
|
|
|
{
|
|
|
|
if (this_board->set_ui_indication)
|
|
|
|
(this_board->set_ui_indication)(ui_indication);
|
|
|
|
}
|
|
|
|
|
2009-01-09 06:32:51 +02:00
|
|
|
static int read_file(const char * filepath, u8 * destination, int size)
|
2008-11-28 12:16:41 +02:00
|
|
|
{
|
2008-11-28 12:16:45 +02:00
|
|
|
int len = size;
|
2008-12-01 03:26:05 +02:00
|
|
|
int ret;
|
2008-11-28 12:16:41 +02:00
|
|
|
|
|
|
|
switch (this_kernel->filesystem) {
|
|
|
|
case FS_EXT2:
|
|
|
|
if (!ext2fs_mount()) {
|
|
|
|
puts("Unable to mount ext2 filesystem\n");
|
2008-12-01 03:26:06 +02:00
|
|
|
indicate(UI_IND_MOUNT_FAIL);
|
2008-12-01 03:26:06 +02:00
|
|
|
return -2; /* death */
|
2008-11-28 12:16:41 +02:00
|
|
|
}
|
|
|
|
puts(" EXT2 open: ");
|
|
|
|
puts(filepath);
|
|
|
|
len = ext2fs_open(filepath);
|
|
|
|
if (len < 0) {
|
2008-11-28 12:16:45 +02:00
|
|
|
puts(" Open failed\n");
|
2008-11-28 12:16:41 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2008-11-28 12:16:45 +02:00
|
|
|
puts(" OK\n");
|
2008-12-01 03:26:05 +02:00
|
|
|
ret = ext2fs_read((char *)destination, size);
|
|
|
|
if (ret < 0) {
|
|
|
|
puts(" Read failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2008-11-28 12:16:41 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FS_FAT:
|
|
|
|
/* FIXME */
|
|
|
|
case FS_RAW:
|
2008-11-28 12:16:45 +02:00
|
|
|
/* any filename-related request in raw filesystem will fail */
|
|
|
|
if (filepath)
|
|
|
|
return -1;
|
2008-11-28 12:16:41 +02:00
|
|
|
puts(" RAW open: +");
|
|
|
|
printdec(partition_offset_blocks);
|
|
|
|
puts(" 512-byte blocks\n");
|
|
|
|
if (this_kernel->block_read(destination,
|
|
|
|
partition_offset_blocks, size >> 9) < 0) {
|
2009-01-09 06:32:46 +02:00
|
|
|
puts("Bad kernel header\n");
|
2008-11-28 12:16:41 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
2008-08-13 02:42:35 +03:00
|
|
|
|
2009-01-09 06:32:49 +02:00
|
|
|
static int do_block_init(void)
|
|
|
|
{
|
|
|
|
static void * last_block_init = NULL;
|
|
|
|
static int last_block_init_result = 0;
|
2009-02-01 21:28:18 +02:00
|
|
|
int fresh = 0;
|
2009-01-09 06:32:49 +02:00
|
|
|
|
|
|
|
/* if this device needs initializing, try to init it */
|
|
|
|
if (!this_kernel->block_init)
|
2009-02-01 21:28:18 +02:00
|
|
|
return 1; /* happy */
|
2009-01-09 06:32:49 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* cache result to limit attempts for same
|
|
|
|
* block device to one time
|
|
|
|
*/
|
2009-02-01 21:28:18 +02:00
|
|
|
if (this_kernel->block_init != last_block_init) {
|
|
|
|
last_block_init = this_kernel->block_init;
|
2009-01-09 06:32:49 +02:00
|
|
|
last_block_init_result = (this_kernel->block_init)();
|
2009-02-01 21:28:18 +02:00
|
|
|
fresh = 1;
|
|
|
|
}
|
2009-01-09 06:32:49 +02:00
|
|
|
|
|
|
|
if (last_block_init_result) {
|
|
|
|
puts("block device init failed\n");
|
2009-02-01 21:28:18 +02:00
|
|
|
if (fresh)
|
2009-01-09 06:32:49 +02:00
|
|
|
indicate(UI_IND_MOUNT_FAIL);
|
2009-02-01 21:28:18 +02:00
|
|
|
|
|
|
|
return 0; /* failed */
|
2009-01-09 06:32:49 +02:00
|
|
|
}
|
|
|
|
last_block_init = this_kernel->block_init;
|
|
|
|
|
2009-02-01 21:28:18 +02:00
|
|
|
return 1; /* happy */
|
2009-01-09 06:32:49 +02:00
|
|
|
}
|
|
|
|
|
2009-01-09 06:32:48 +02:00
|
|
|
static int do_partitions(void *kernel_dram)
|
|
|
|
{
|
|
|
|
unsigned char *p = kernel_dram;
|
|
|
|
|
|
|
|
/* if there's a partition table implied, parse it, otherwise
|
|
|
|
* just use a fixed offset
|
|
|
|
*/
|
|
|
|
if (!this_kernel->partition_index) {
|
|
|
|
partition_offset_blocks =
|
|
|
|
this_kernel->offset_blocks512_if_no_partition;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((int)this_kernel->block_read(kernel_dram, 0, 4) < 0) {
|
|
|
|
puts("Bad partition read\n");
|
|
|
|
indicate(UI_IND_MOUNT_FAIL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((p[0x1fe] != 0x55) || (p[0x1ff] != 0xaa)) {
|
|
|
|
puts("partition signature missing\n");
|
|
|
|
indicate(UI_IND_MOUNT_FAIL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
p += 0x1be + 8 + (0x10 * (this_kernel->partition_index - 1));
|
|
|
|
|
|
|
|
partition_offset_blocks = (((u32)p[3]) << 24) |
|
|
|
|
(((u32)p[2]) << 16) |
|
|
|
|
(((u32)p[1]) << 8) |
|
|
|
|
p[0];
|
|
|
|
partition_length_blocks = (((u32)p[7]) << 24) |
|
|
|
|
(((u32)p[6]) << 16) |
|
|
|
|
(((u32)p[5]) << 8) |
|
|
|
|
p[4];
|
|
|
|
|
|
|
|
puts(" Partition: ");
|
|
|
|
printdec(this_kernel->partition_index);
|
|
|
|
puts(" start +");
|
|
|
|
printdec(partition_offset_blocks);
|
|
|
|
puts(" 512-byte blocks, size ");
|
|
|
|
printdec(partition_length_blocks / 2048);
|
|
|
|
puts(" MiB\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-01-09 06:32:47 +02:00
|
|
|
static void do_params(unsigned initramfs_len,
|
|
|
|
const char *commandline_rootfs_append)
|
2008-08-13 02:42:35 +03:00
|
|
|
{
|
2008-11-28 12:16:40 +02:00
|
|
|
const struct board_variant * board_variant =
|
|
|
|
(this_board->get_board_variant)();
|
2009-01-09 06:32:47 +02:00
|
|
|
const char *p;
|
|
|
|
char * cmdline;
|
|
|
|
struct tag *params = (struct tag *)this_board->linux_tag_placement;
|
|
|
|
|
|
|
|
/* eat leading white space */
|
|
|
|
for (p = this_board->commandline_board; *p == ' '; p++);
|
|
|
|
|
|
|
|
/* first tag */
|
|
|
|
params->hdr.tag = ATAG_CORE;
|
|
|
|
params->hdr.size = tag_size(tag_core);
|
|
|
|
params->u.core.flags = 0;
|
|
|
|
params->u.core.pagesize = 0;
|
|
|
|
params->u.core.rootdev = 0;
|
|
|
|
params = tag_next(params);
|
|
|
|
|
|
|
|
/* revision tag */
|
|
|
|
params->hdr.tag = ATAG_REVISION;
|
|
|
|
params->hdr.size = tag_size(tag_revision);
|
|
|
|
params->u.revision.rev = board_variant->machine_revision;
|
|
|
|
params = tag_next(params);
|
|
|
|
|
|
|
|
/* memory tags */
|
|
|
|
params->hdr.tag = ATAG_MEM;
|
|
|
|
params->hdr.size = tag_size(tag_mem32);
|
|
|
|
params->u.mem.start = this_board->linux_mem_start;
|
|
|
|
params->u.mem.size = this_board->linux_mem_size;
|
|
|
|
params = tag_next(params);
|
|
|
|
|
|
|
|
if (this_kernel->initramfs_filepath) {
|
|
|
|
/* INITRD2 tag */
|
|
|
|
params->hdr.tag = ATAG_INITRD2;
|
|
|
|
params->hdr.size = tag_size(tag_initrd);
|
|
|
|
params->u.initrd.start = this_board->linux_mem_start +
|
|
|
|
INITRD_OFFSET;
|
|
|
|
params->u.initrd.size = initramfs_len;
|
|
|
|
params = tag_next(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* kernel commandline */
|
|
|
|
|
|
|
|
cmdline = params->u.cmdline.cmdline;
|
2009-02-03 20:06:38 +02:00
|
|
|
|
|
|
|
/* start with the fixed device part of the commandline */
|
|
|
|
|
2009-01-09 06:32:47 +02:00
|
|
|
cmdline += strlen(strcpy(cmdline, p));
|
2009-02-03 20:06:38 +02:00
|
|
|
|
|
|
|
/* if the board itself needs a computed commandline, add it now */
|
|
|
|
|
|
|
|
if (this_board->append_device_specific_cmdline)
|
|
|
|
cmdline = (this_board->append_device_specific_cmdline)(cmdline);
|
|
|
|
|
|
|
|
/* If he is giving an append commandline for this rootfs, apply that */
|
|
|
|
|
2009-01-09 06:32:47 +02:00
|
|
|
if (this_kernel->commandline_append)
|
|
|
|
cmdline += strlen(strcpy(cmdline,
|
|
|
|
this_kernel->commandline_append));
|
|
|
|
if (commandline_rootfs_append[0])
|
|
|
|
cmdline += strlen(strcpy(cmdline,
|
|
|
|
commandline_rootfs_append));
|
|
|
|
|
2009-01-31 19:23:29 +02:00
|
|
|
/* deal with any trailing newlines that hitched a ride */
|
|
|
|
|
2009-02-03 20:06:38 +02:00
|
|
|
while (*(cmdline - 1) == '\n')
|
|
|
|
cmdline--;
|
|
|
|
|
|
|
|
*cmdline = '\0';
|
2009-01-31 19:23:29 +02:00
|
|
|
|
2009-01-09 06:32:47 +02:00
|
|
|
/*
|
|
|
|
* if he's still holding down the UI_ACTION_SKIPKERNEL key
|
|
|
|
* now we finished loading the kernel, take it to mean he wants
|
|
|
|
* to have the debugging options added to the commandline
|
|
|
|
*/
|
|
|
|
|
2009-01-19 03:37:09 +02:00
|
|
|
if (this_board->commandline_board_debug && this_board->get_ui_debug)
|
|
|
|
if ((this_board->get_ui_debug)())
|
2009-01-09 06:32:47 +02:00
|
|
|
cmdline += strlen(strcpy(cmdline, this_board->
|
|
|
|
commandline_board_debug));
|
|
|
|
|
|
|
|
params->hdr.tag = ATAG_CMDLINE;
|
|
|
|
params->hdr.size = (sizeof(struct tag_header) +
|
|
|
|
strlen(params->u.cmdline.cmdline) + 1 + 4) >> 2;
|
|
|
|
|
|
|
|
puts(" Cmdline: ");
|
|
|
|
puts(params->u.cmdline.cmdline);
|
|
|
|
puts("\n");
|
|
|
|
|
|
|
|
params = tag_next(params);
|
|
|
|
|
|
|
|
/* needs to always be the last tag */
|
|
|
|
params->hdr.tag = ATAG_NONE;
|
|
|
|
params->hdr.size = 0;
|
|
|
|
}
|
|
|
|
|
2009-01-09 06:32:49 +02:00
|
|
|
static int do_crc(const image_header_t *hdr, const void *kernel_dram)
|
|
|
|
{
|
|
|
|
unsigned long crc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* It's good for now to know that our kernel is intact from
|
|
|
|
* the storage before we jump into it and maybe crash silently
|
|
|
|
* even though it costs us some time
|
|
|
|
*/
|
|
|
|
crc = crc32(0, kernel_dram + sizeof(image_header_t),
|
|
|
|
__be32_to_cpu(hdr->ih_size));
|
|
|
|
if (crc == __be32_to_cpu(hdr->ih_dcrc))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
puts("\nKernel CRC ERROR: read 0x");
|
|
|
|
print32(crc);
|
|
|
|
puts(" vs hdr CRC 0x");
|
|
|
|
print32(__be32_to_cpu(hdr->ih_dcrc));
|
|
|
|
puts("\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-09 06:32:52 +02:00
|
|
|
static the_kernel_fn load_uimage(void *kernel_dram)
|
|
|
|
{
|
|
|
|
image_header_t *hdr;
|
|
|
|
u32 kernel_size;
|
|
|
|
|
|
|
|
hdr = (image_header_t *)kernel_dram;
|
|
|
|
|
|
|
|
if (__be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
|
|
|
|
puts("bad magic ");
|
|
|
|
print32(hdr->ih_magic);
|
|
|
|
puts("\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
puts(" Found: \"");
|
|
|
|
puts((const char *)hdr->ih_name);
|
|
|
|
puts("\"\n Size: ");
|
|
|
|
printdec(__be32_to_cpu(hdr->ih_size) >> 10);
|
|
|
|
puts(" KiB\n");
|
|
|
|
|
|
|
|
kernel_size = ((__be32_to_cpu(hdr->ih_size) +
|
|
|
|
sizeof(image_header_t) + 2048) & ~(2048 - 1));
|
|
|
|
|
|
|
|
if (read_file(this_kernel->filepath, kernel_dram, kernel_size) < 0) {
|
|
|
|
indicate(UI_IND_KERNEL_PULL_FAIL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
indicate(UI_IND_KERNEL_PULL_OK);
|
|
|
|
|
|
|
|
if (!do_crc(hdr, kernel_dram))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (the_kernel_fn) (((char *)hdr) + sizeof(image_header_t));
|
|
|
|
}
|
|
|
|
|
2009-01-09 06:32:53 +02:00
|
|
|
static the_kernel_fn load_zimage(void *kernel_dram)
|
|
|
|
{
|
|
|
|
u32 magic = *(u32 *) (kernel_dram + 0x24);
|
|
|
|
u32 size = *(u32 *) (kernel_dram + 0x2c);
|
|
|
|
int got;
|
|
|
|
|
|
|
|
if (magic != 0x016f2818) {
|
|
|
|
puts("bad magic ");
|
|
|
|
print32(magic);
|
|
|
|
puts("\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
puts(" Size: ");
|
|
|
|
printdec(size >> 10);
|
|
|
|
puts(" KiB\n");
|
|
|
|
|
|
|
|
got = read_file(this_kernel->filepath, kernel_dram, size);
|
|
|
|
if (got < 0) {
|
|
|
|
indicate(UI_IND_KERNEL_PULL_FAIL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (got != size) {
|
|
|
|
puts("short kernel\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
indicate(UI_IND_KERNEL_PULL_OK);
|
|
|
|
|
|
|
|
return (the_kernel_fn) kernel_dram;
|
|
|
|
}
|
|
|
|
|
2009-01-09 06:32:47 +02:00
|
|
|
static void try_this_kernel(void)
|
|
|
|
{
|
2009-01-09 06:32:51 +02:00
|
|
|
the_kernel_fn the_kernel;
|
2008-11-28 12:16:41 +02:00
|
|
|
unsigned int initramfs_len = 0;
|
2008-11-28 12:16:45 +02:00
|
|
|
static char commandline_rootfs_append[512] = "";
|
2008-12-01 03:26:06 +02:00
|
|
|
int ret;
|
2009-01-09 06:32:46 +02:00
|
|
|
void * kernel_dram = (void *)this_board->linux_mem_start + 0x8000;
|
2008-11-28 12:16:37 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
partition_offset_blocks = 0;
|
|
|
|
partition_length_blocks = 0;
|
2008-11-28 12:16:37 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
puts("\nTrying kernel: ");
|
|
|
|
puts(this_kernel->name);
|
|
|
|
puts("\n");
|
2008-11-28 12:16:36 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
indicate(UI_IND_MOUNT_PART);
|
2008-11-28 12:16:36 +02:00
|
|
|
|
2009-01-09 06:32:49 +02:00
|
|
|
if (!do_block_init())
|
|
|
|
return;
|
2008-11-28 12:16:36 +02:00
|
|
|
|
2009-01-09 06:32:48 +02:00
|
|
|
if (!do_partitions(kernel_dram))
|
|
|
|
return;
|
2009-01-09 06:32:46 +02:00
|
|
|
|
|
|
|
/* does he want us to skip this? */
|
|
|
|
|
|
|
|
ret = read_file(this_board->noboot, kernel_dram, 512);
|
|
|
|
if (ret != -1) {
|
|
|
|
/* -2 (mount fail) should make us give up too */
|
|
|
|
if (ret >= 0) {
|
|
|
|
puts(" (Skipping on finding ");
|
|
|
|
puts(this_board->noboot);
|
|
|
|
puts(")\n");
|
|
|
|
indicate(UI_IND_SKIPPING);
|
2008-11-28 12:16:37 +02:00
|
|
|
}
|
2009-01-09 06:32:46 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-11-28 12:16:37 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
/* is there a commandline append file? */
|
2008-11-28 12:16:37 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
commandline_rootfs_append[0] = '\0';
|
|
|
|
read_file(this_board->append, (u8 *)commandline_rootfs_append, 512);
|
2008-11-28 12:16:37 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
indicate(UI_IND_KERNEL_PULL);
|
2008-11-28 12:16:37 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
/* pull the kernel image */
|
2008-11-28 12:16:37 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
if (read_file(this_kernel->filepath, kernel_dram, 4096) < 0)
|
|
|
|
return;
|
2008-11-28 12:16:41 +02:00
|
|
|
|
2009-01-09 06:32:52 +02:00
|
|
|
the_kernel = load_uimage(kernel_dram);
|
2009-01-09 06:32:53 +02:00
|
|
|
if (!the_kernel)
|
|
|
|
the_kernel = load_zimage(kernel_dram);
|
2009-01-09 06:32:52 +02:00
|
|
|
if (!the_kernel)
|
2009-01-09 06:32:46 +02:00
|
|
|
return;
|
2008-11-28 12:16:36 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
/* initramfs if needed */
|
|
|
|
|
|
|
|
if (this_kernel->initramfs_filepath) {
|
|
|
|
indicate(UI_IND_INITRAMFS_PULL);
|
|
|
|
initramfs_len = read_file(this_kernel->initramfs_filepath,
|
|
|
|
(u8 *)this_board->linux_mem_start + INITRD_OFFSET,
|
|
|
|
16 * 1024 * 1024);
|
|
|
|
if (initramfs_len < 0) {
|
|
|
|
puts("initramfs load failed\n");
|
|
|
|
indicate(UI_IND_INITRAMFS_PULL_FAIL);
|
|
|
|
return;
|
2008-11-28 12:16:41 +02:00
|
|
|
}
|
2009-01-09 06:32:46 +02:00
|
|
|
indicate(UI_IND_INITRAMFS_PULL_OK);
|
|
|
|
}
|
2008-11-28 12:16:41 +02:00
|
|
|
|
2009-01-09 06:32:47 +02:00
|
|
|
do_params(initramfs_len, commandline_rootfs_append);
|
2008-11-28 12:16:36 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
/* give board implementation a chance to shut down
|
|
|
|
* anything it may have going on, leave GPIO set for Linux
|
|
|
|
*/
|
|
|
|
if (this_board->close)
|
|
|
|
(this_board->close)();
|
2008-11-28 12:16:39 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
puts("Starting --->\n\n");
|
2009-01-09 06:32:46 +02:00
|
|
|
indicate(UI_IND_KERNEL_START);
|
2008-11-28 12:16:36 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
/*
|
|
|
|
* ooh that's it, we're gonna try boot this image!
|
|
|
|
* never mind the cache, Linux will take care of it
|
|
|
|
*/
|
|
|
|
the_kernel(0, this_board->linux_machine_id,
|
|
|
|
this_board->linux_tag_placement);
|
2008-11-28 12:16:36 +02:00
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
/* we won't come back here no matter what */
|
|
|
|
}
|
|
|
|
|
|
|
|
void bootloader_second_phase(void)
|
|
|
|
{
|
2009-02-03 20:06:36 +02:00
|
|
|
/* give device a chance to print device-specific things */
|
|
|
|
|
|
|
|
if (this_board->post_serial_init)
|
|
|
|
(this_board->post_serial_init)();
|
|
|
|
|
2009-01-09 06:32:46 +02:00
|
|
|
/* we try the possible kernels for this board in order */
|
|
|
|
|
|
|
|
for (this_kernel = this_board->kernel_source; this_kernel->name;
|
|
|
|
this_kernel++)
|
|
|
|
try_this_kernel();
|
2008-08-13 02:42:35 +03:00
|
|
|
|
2008-11-28 12:16:36 +02:00
|
|
|
/* none of the kernels worked out */
|
2008-08-13 02:42:35 +03:00
|
|
|
|
2008-11-28 12:16:42 +02:00
|
|
|
puts("\nNo usable kernel image found\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sit there doing a memory test in this case.
|
|
|
|
*
|
|
|
|
* This phase 2 code will get destroyed but it's OK, we won't be
|
|
|
|
* coming back and the whole memory test and dependency functions are
|
|
|
|
* in phase 1 / steppingstone, so we can test entire memory range.
|
|
|
|
*
|
|
|
|
* It means we just boot with SD Card with kernel(s) renamed or removed
|
|
|
|
* to provoke memory test.
|
|
|
|
*/
|
|
|
|
|
2008-12-01 03:26:06 +02:00
|
|
|
indicate(UI_IND_MEM_TEST);
|
|
|
|
|
2008-11-28 12:16:42 +02:00
|
|
|
memory_test((void *)this_board->linux_mem_start,
|
|
|
|
this_board->linux_mem_size);
|
|
|
|
|
2008-08-13 02:42:35 +03:00
|
|
|
}
|