Fixed tools/env utilities
[u-boot-openmoko/mini2440.git] / common / cmd_bootldr.c
blobe6474aab22bfae66844a05fdda9e2865b9e124f7
1 /*
2 * U-boot - bootldr.c
4 * Copyright (c) 2005-2008 Analog Devices Inc.
6 * See file CREDITS for list of people who contributed to this
7 * project.
9 * Licensed under the GPL-2 or later.
12 #include <config.h>
13 #include <common.h>
14 #include <command.h>
16 #include <asm/blackfin.h>
17 #include <asm/mach-common/bits/bootrom.h>
20 * the bootldr command loads an address, checks to see if there
21 * is a Boot stream that the on-chip BOOTROM can understand,
22 * and loads it via the BOOTROM Callback. It is possible
23 * to also add booting from SPI, or TWI, but this function does
24 * not currently support that.
27 int do_bootldr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
29 void *addr;
30 uint32_t *data;
32 /* Get the address */
33 if (argc < 2)
34 addr = (void *)load_addr;
35 else
36 addr = (void *)simple_strtoul(argv[1], NULL, 16);
38 /* Check if it is a LDR file */
39 data = addr;
40 #if defined(__ADSPBF54x__) || defined(__ADSPBF52x__)
41 if ((*data & 0xFF000000) == 0xAD000000 && data[2] == 0x00000000) {
42 #else
43 if (*data == 0xFF800060 || *data == 0xFF800040 || *data == 0xFF800020) {
44 #endif
45 /* We want to boot from FLASH or SDRAM */
46 printf("## Booting ldr image at 0x%p ...\n", addr);
48 icache_disable();
49 dcache_disable();
51 __asm__(
52 "jump (%1);"
54 : "q7" (addr), "a" (_BOOTROM_MEMBOOT));
55 } else
56 printf("## No ldr image at address 0x%p\n", addr);
58 return 0;
61 U_BOOT_CMD(bootldr, 2, 0, do_bootldr,
62 "bootldr - boot ldr image from memory\n",
63 "[addr]\n"
64 " - boot ldr image stored in memory\n");