Skip to content
Snippets Groups Projects
image.c 32.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • 		bootstage_mark(BOOTSTAGE_ID_NO_RAMDISK);
    
    		debug("## No init Ramdisk\n");
    
    	} else {
    		*rd_start = rd_data;
    		*rd_end = rd_data + rd_len;
    	}
    
    	debug("   ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n",
    
    #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
    
     * boot_ramdisk_high - relocate init ramdisk
    
     * @lmb: pointer to lmb handle, will be used for memory mgmt
    
     * @rd_data: ramdisk data start address
     * @rd_len: ramdisk data length
     * @initrd_start: pointer to a ulong variable, will hold final init ramdisk
     *      start address (after possible relocation)
     * @initrd_end: pointer to a ulong variable, will hold final init ramdisk
     *      end address (after possible relocation)
     *
    
     * boot_ramdisk_high() takes a relocation hint from "initrd_high" environment
    
     * variable and if requested ramdisk data is moved to a specified location.
     *
    
     * Initrd_start and initrd_end are set to final (after relocation) ramdisk
     * start/end addresses if ramdisk image start and len were provided,
     * otherwise set initrd_start and initrd_end set to zeros.
     *
    
    int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
    
    		  ulong *initrd_start, ulong *initrd_end)
    
    {
    	char	*s;
    	ulong	initrd_high;
    	int	initrd_copy_to_ram = 1;
    
    
    	if ((s = getenv("initrd_high")) != NULL) {
    
    		/* a value of "no" or a similar string will act like 0,
    		 * turning the "load high" feature off. This is intentional.
    		 */
    
    		initrd_high = simple_strtoul(s, NULL, 16);
    
    		if (initrd_high == ~0)
    			initrd_copy_to_ram = 0;
    	} else {
    		/* not set, no restrictions to load high */
    		initrd_high = ~0;
    	}
    
    
    
    #ifdef CONFIG_LOGBUFFER
    	/* Prevent initrd from overwriting logbuffer */
    	lmb_reserve(lmb, logbuffer_base() - LOGBUFF_OVERHEAD, LOGBUFF_RESERVE);
    #endif
    
    
    	debug("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
    
    			initrd_high, initrd_copy_to_ram);
    
    	if (rd_data) {
    		if (!initrd_copy_to_ram) {	/* zero-copy ramdisk support */
    
    			debug("   in-place initrd\n");
    
    			*initrd_start = rd_data;
    			*initrd_end = rd_data + rd_len;
    
    			lmb_reserve(lmb, rd_data, rd_len);
    
    			if (initrd_high)
    
    				*initrd_start = (ulong)lmb_alloc_base(lmb,
    						rd_len, 0x1000, initrd_high);
    
    				*initrd_start = (ulong)lmb_alloc(lmb, rd_len,
    								 0x1000);
    
    
    			if (*initrd_start == 0) {
    
    				puts("ramdisk - allocation error\n");
    
    			bootstage_mark(BOOTSTAGE_ID_COPY_RAMDISK);
    
    
    			*initrd_end = *initrd_start + rd_len;
    
    			printf("   Loading Ramdisk to %08lx, end %08lx ... ",
    
    			memmove_wd((void *)*initrd_start,
    
    					(void *)rd_data, rd_len, CHUNKSZ);
    
    
    #ifdef CONFIG_MP
    			/*
    			 * Ensure the image is flushed to memory to handle
    			 * AMP boot scenarios in which we might not be
    			 * HW cache coherent
    			 */
    			flush_cache((unsigned long)*initrd_start, rd_len);
    #endif
    
    			puts("OK\n");
    
    		}
    	} else {
    		*initrd_start = 0;
    		*initrd_end = 0;
    	}
    
    	debug("   ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n",
    
    			*initrd_start, *initrd_end);
    
    #endif /* CONFIG_SYS_BOOT_RAMDISK_HIGH */
    
    #ifdef CONFIG_SYS_BOOT_GET_CMDLINE
    
     * boot_get_cmdline - allocate and initialize kernel cmdline
    
     * @lmb: pointer to lmb handle, will be used for memory mgmt
    
     * @cmd_start: pointer to a ulong variable, will hold cmdline start
     * @cmd_end: pointer to a ulong variable, will hold cmdline end
     *
    
     * boot_get_cmdline() allocates space for kernel command line below
    
     * BOOTMAPSZ + getenv_bootm_low() address. If "bootargs" U-boot environemnt
    
     * variable is present its contents is copied to allocated kernel
     * command line.
     *
     * returns:
    
     *      0 - success
     *     -1 - failure
    
    int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
    
    	cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf,
    
    				getenv_bootm_mapsize() + getenv_bootm_low());
    
    
    	if (cmdline == NULL)
    		return -1;
    
    
    	if ((s = getenv("bootargs")) == NULL)
    		s = "";
    
    	strcpy(cmdline, s);
    
    	*cmd_start = (ulong) & cmdline[0];
    	*cmd_end = *cmd_start + strlen(cmdline);
    
    
    	debug("## cmdline at 0x%08lx ... 0x%08lx\n", *cmd_start, *cmd_end);
    
    #endif /* CONFIG_SYS_BOOT_GET_CMDLINE */
    
    #ifdef CONFIG_SYS_BOOT_GET_KBD
    
     * boot_get_kbd - allocate and initialize kernel copy of board info
    
     * @lmb: pointer to lmb handle, will be used for memory mgmt
    
     * @kbd: double pointer to board info data
     *
    
     * boot_get_kbd() allocates space for kernel copy of board info data below
    
     * BOOTMAPSZ + getenv_bootm_low() address and kernel board info is initialized
     * with the current u-boot board info data.
    
     *      0 - success
     *     -1 - failure
    
    int boot_get_kbd(struct lmb *lmb, bd_t **kbd)
    
    	*kbd = (bd_t *)(ulong)lmb_alloc_base(lmb, sizeof(bd_t), 0xf,
    
    				getenv_bootm_mapsize() + getenv_bootm_low());
    
    	if (*kbd == NULL)
    		return -1;
    
    
    	debug("## kernel board info at 0x%08lx\n", (ulong)*kbd);
    
    
    #if defined(DEBUG) && defined(CONFIG_CMD_BDI)
    	do_bdinfo(NULL, 0, 0, NULL);
    #endif
    
    
    #endif /* CONFIG_SYS_BOOT_GET_KBD */
    
    
    #ifdef CONFIG_LMB
    int image_setup_linux(bootm_headers_t *images)
    {
    	ulong of_size = images->ft_len;
    	char **of_flat_tree = &images->ft_addr;
    	ulong *initrd_start = &images->initrd_start;
    	ulong *initrd_end = &images->initrd_end;
    	struct lmb *lmb = &images->lmb;
    	ulong rd_len;
    	int ret;
    
    	if (IMAGE_ENABLE_OF_LIBFDT)
    		boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
    
    	if (IMAGE_BOOT_GET_CMDLINE) {
    		ret = boot_get_cmdline(lmb, &images->cmdline_start,
    				&images->cmdline_end);
    		if (ret) {
    			puts("ERROR with allocation of cmdline\n");
    			return ret;
    		}
    	}
    	if (IMAGE_ENABLE_RAMDISK_HIGH) {
    		rd_len = images->rd_end - images->rd_start;
    		ret = boot_ramdisk_high(lmb, images->rd_start, rd_len,
    				initrd_start, initrd_end);
    		if (ret)
    			return ret;
    	}
    
    	if (IMAGE_ENABLE_OF_LIBFDT) {
    		ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size);
    		if (ret)
    			return ret;
    	}
    
    	if (IMAGE_ENABLE_OF_LIBFDT && of_size) {
    		ret = image_setup_libfdt(images, *of_flat_tree, of_size, lmb);
    		if (ret)
    			return ret;
    	}
    
    	return 0;
    }
    #endif /* CONFIG_LMB */
    
    #endif /* !USE_HOSTCC */