1fea25720SGraeme Russ /* 2fea25720SGraeme Russ * (C) Copyright 2002 3fea25720SGraeme Russ * Sysgo Real-Time Solutions, GmbH <www.elinos.com> 4fea25720SGraeme Russ * Marius Groeger <mgroeger@sysgo.de> 5fea25720SGraeme Russ * 6fea25720SGraeme Russ * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) 7fea25720SGraeme Russ * 8fea25720SGraeme Russ * See file CREDITS for list of people who contributed to this 9fea25720SGraeme Russ * project. 10fea25720SGraeme Russ * 11fea25720SGraeme Russ * This program is free software; you can redistribute it and/or 12fea25720SGraeme Russ * modify it under the terms of the GNU General Public License as 13fea25720SGraeme Russ * published by the Free Software Foundation; either version 2 of 14fea25720SGraeme Russ * the License, or (at your option) any later version. 15fea25720SGraeme Russ * 16fea25720SGraeme Russ * This program is distributed in the hope that it will be useful, 17fea25720SGraeme Russ * but WITHOUT ANY WARRANTY; without even the implied warranty of 18fea25720SGraeme Russ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19fea25720SGraeme Russ * GNU General Public License for more details. 20fea25720SGraeme Russ * 21fea25720SGraeme Russ * You should have received a copy of the GNU General Public License 22fea25720SGraeme Russ * along with this program; if not, write to the Free Software 23fea25720SGraeme Russ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 24fea25720SGraeme Russ * MA 02111-1307 USA 25fea25720SGraeme Russ */ 26fea25720SGraeme Russ 27fea25720SGraeme Russ #include <common.h> 28fea25720SGraeme Russ #include <command.h> 29fea25720SGraeme Russ #include <image.h> 30fea25720SGraeme Russ #include <u-boot/zlib.h> 3169370d14SGabe Black #include <asm/bootparam.h> 32fea25720SGraeme Russ #include <asm/byteorder.h> 33fea25720SGraeme Russ #include <asm/zimage.h> 34fea25720SGraeme Russ 3569370d14SGabe Black #define COMMAND_LINE_OFFSET 0x9000 3669370d14SGabe Black 37fea25720SGraeme Russ /*cmd_boot.c*/ 3883088afbSGraeme Russ int do_bootm_linux(int flag, int argc, char * const argv[], 3983088afbSGraeme Russ bootm_headers_t *images) 40fea25720SGraeme Russ { 4169370d14SGabe Black struct boot_params *base_ptr = NULL; 42fea25720SGraeme Russ ulong os_data, os_len; 43fea25720SGraeme Russ image_header_t *hdr; 44233dbc11SGabe Black void *load_address; 45fea25720SGraeme Russ 46fea25720SGraeme Russ #if defined(CONFIG_FIT) 47fea25720SGraeme Russ const void *data; 48fea25720SGraeme Russ size_t len; 49fea25720SGraeme Russ #endif 50fea25720SGraeme Russ 51*7af26b16SSimon Glass if (flag & BOOTM_STATE_OS_PREP) 52*7af26b16SSimon Glass return 0; 53fea25720SGraeme Russ if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) 54fea25720SGraeme Russ return 1; 55fea25720SGraeme Russ 56fea25720SGraeme Russ if (images->legacy_hdr_valid) { 57fea25720SGraeme Russ hdr = images->legacy_hdr_os; 58fea25720SGraeme Russ if (image_check_type(hdr, IH_TYPE_MULTI)) { 59fea25720SGraeme Russ /* if multi-part image, we need to get first subimage */ 60fea25720SGraeme Russ image_multi_getimg(hdr, 0, &os_data, &os_len); 61fea25720SGraeme Russ } else { 62fea25720SGraeme Russ /* otherwise get image data */ 63fea25720SGraeme Russ os_data = image_get_data(hdr); 64fea25720SGraeme Russ os_len = image_get_data_size(hdr); 65fea25720SGraeme Russ } 66fea25720SGraeme Russ #if defined(CONFIG_FIT) 67fea25720SGraeme Russ } else if (images->fit_uname_os) { 68bdc7d5cdSSimon Glass int ret; 69bdc7d5cdSSimon Glass 70fea25720SGraeme Russ ret = fit_image_get_data(images->fit_hdr_os, 71fea25720SGraeme Russ images->fit_noffset_os, &data, &len); 72fea25720SGraeme Russ if (ret) { 73fea25720SGraeme Russ puts("Can't get image data/size!\n"); 74fea25720SGraeme Russ goto error; 75fea25720SGraeme Russ } 76fea25720SGraeme Russ os_data = (ulong)data; 77fea25720SGraeme Russ os_len = (ulong)len; 78fea25720SGraeme Russ #endif 79fea25720SGraeme Russ } else { 80fea25720SGraeme Russ puts("Could not find kernel image!\n"); 81fea25720SGraeme Russ goto error; 82fea25720SGraeme Russ } 83fea25720SGraeme Russ 84a76fc70eSGraeme Russ #ifdef CONFIG_CMD_ZBOOT 8569370d14SGabe Black base_ptr = load_zimage((void *)os_data, os_len, &load_address); 86a76fc70eSGraeme Russ #endif 87fea25720SGraeme Russ 88fea25720SGraeme Russ if (NULL == base_ptr) { 89fea25720SGraeme Russ printf("## Kernel loading failed ...\n"); 90fea25720SGraeme Russ goto error; 9169370d14SGabe Black } 92fea25720SGraeme Russ 9369370d14SGabe Black if (setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET, 9469370d14SGabe Black 0, images->rd_start, 9569370d14SGabe Black images->rd_end - images->rd_start)) { 9669370d14SGabe Black printf("## Setting up boot parameters failed ...\n"); 9769370d14SGabe Black goto error; 98fea25720SGraeme Russ } 99fea25720SGraeme Russ 100233dbc11SGabe Black boot_zimage(base_ptr, load_address); 101fea25720SGraeme Russ /* does not return */ 102fea25720SGraeme Russ 103fea25720SGraeme Russ error: 104fea25720SGraeme Russ return 1; 105fea25720SGraeme Russ } 106