Skip to content
Snippets Groups Projects
Select Git revision
  • eca3aeb352c964bdb28b8e191d6326370245e03f
  • master default protected
  • early-display
  • variant-emmc-nvme-boot
  • 2023-01-25
  • v3
  • variant-emmc-nvme-boot
  • 2020-06-01
8 results

cpu_init.c

Blame
  • Forked from Reform / reform-boundary-uboot
    Source project has a limited visibility.
    default_image.c 4.54 KiB
    /*
     * (C) Copyright 2008 Semihalf
     *
     * (C) Copyright 2000-2004
     * DENX Software Engineering
     * Wolfgang Denk, wd@denx.de
     *
     * Updated-by: Prafulla Wadaskar <prafulla@marvell.com>
     *		default_image specific code abstracted from mkimage.c
     *		some functions added to address abstraction
     *
     * All rights reserved.
     *
     * SPDX-License-Identifier:	GPL-2.0+
     */
    
    #include "imagetool.h"
    #include "mkimage.h"
    
    #include <image.h>
    #include <u-boot/crc.h>
    
    static image_header_t header;
    
    static int image_check_image_types(uint8_t type)
    {
    	if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
    	    (type == IH_TYPE_KERNEL_NOLOAD))
    		return EXIT_SUCCESS;
    	else
    		return EXIT_FAILURE;
    }
    
    static int image_check_params(struct image_tool_params *params)
    {
    	return	((params->dflag && (params->fflag || params->lflag)) ||
    		(params->fflag && (params->dflag || params->lflag)) ||
    		(params->lflag && (params->dflag || params->fflag)));
    }
    
    static int image_verify_header(unsigned char *ptr, int image_size,
    			struct image_tool_params *params)
    {
    	uint32_t len;
    	const unsigned char *data;
    	uint32_t checksum;
    	image_header_t header;
    	image_header_t *hdr = &header;
    
    	/*
    	 * create copy of header so that we can blank out the
    	 * checksum field for checking - this can't be done
    	 * on the PROT_READ mapped data.
    	 */
    	memcpy(hdr, ptr, sizeof(image_header_t));
    
    	if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
    		debug("%s: Bad Magic Number: \"%s\" is no valid image\n",
    		      params->cmdname, params->imagefile);
    		return -FDT_ERR_BADMAGIC;
    	}
    
    	data = (const unsigned char *)hdr;
    	len  = sizeof(image_header_t);
    
    	checksum = be32_to_cpu(hdr->ih_hcrc);
    	hdr->ih_hcrc = cpu_to_be32(0);	/* clear for re-calculation */
    
    	if (crc32(0, data, len) != checksum) {
    		debug("%s: ERROR: \"%s\" has bad header checksum!\n",