Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
638e5af7da | ||
|
|
eb3a1b3ab6 | ||
|
|
b5d6220dd2 | ||
|
|
4a03fbc8bb | ||
|
|
5841e78ed6 | ||
|
|
8fa2f3610d |
33
boot/bootm.c
33
boot/bootm.c
@@ -1185,6 +1185,39 @@ int bootm_run(struct bootm_info *bmi)
|
|||||||
|
|
||||||
int bootz_run(struct bootm_info *bmi)
|
int bootz_run(struct bootm_info *bmi)
|
||||||
{
|
{
|
||||||
|
struct bootm_headers *images = bmi->images;
|
||||||
|
ulong zi_start, zi_end;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = bootm_run_states(bmi, BOOTM_STATE_START);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
images->ep = bmi->addr_img ? hextoul(bmi->addr_img, NULL) :
|
||||||
|
image_load_addr;
|
||||||
|
|
||||||
|
ret = bootz_setup(images->ep, &zi_start, &zi_end);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
lmb_reserve(images->ep, zi_end - zi_start);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
|
||||||
|
* have a header that provide this informaiton.
|
||||||
|
*/
|
||||||
|
if (bootm_find_images(images->ep, bmi->conf_ramdisk, bmi->conf_fdt,
|
||||||
|
images->ep, zi_end - zi_start))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We are doing the BOOTM_STATE_LOADOS state ourselves, so must
|
||||||
|
* disable interrupts ourselves
|
||||||
|
*/
|
||||||
|
bootm_disable_interrupts();
|
||||||
|
|
||||||
|
images->os.os = IH_OS_LINUX;
|
||||||
|
|
||||||
return boot_run(bmi, "bootz", 0);
|
return boot_run(bmi, "bootz", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
cmd/bootz.c
65
cmd/bootz.c
@@ -20,56 +20,6 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* zImage booting support
|
|
||||||
*/
|
|
||||||
static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
||||||
char *const argv[], struct bootm_headers *images)
|
|
||||||
{
|
|
||||||
ulong zi_start, zi_end;
|
|
||||||
struct bootm_info bmi;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
bootm_init(&bmi);
|
|
||||||
if (argc)
|
|
||||||
bmi.addr_img = argv[0];
|
|
||||||
if (argc > 1)
|
|
||||||
bmi.conf_ramdisk = argv[1];
|
|
||||||
if (argc > 2)
|
|
||||||
bmi.conf_fdt = argv[2];
|
|
||||||
/* do not set up argc and argv[] since nothing uses them */
|
|
||||||
|
|
||||||
ret = bootm_run_states(&bmi, BOOTM_STATE_START);
|
|
||||||
|
|
||||||
/* Setup Linux kernel zImage entry point */
|
|
||||||
if (!argc) {
|
|
||||||
images->ep = image_load_addr;
|
|
||||||
debug("* kernel: default image load address = 0x%08lx\n",
|
|
||||||
image_load_addr);
|
|
||||||
} else {
|
|
||||||
images->ep = hextoul(argv[0], NULL);
|
|
||||||
debug("* kernel: cmdline image address = 0x%08lx\n",
|
|
||||||
images->ep);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = bootz_setup(images->ep, &zi_start, &zi_end);
|
|
||||||
if (ret != 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
lmb_reserve(images->ep, zi_end - zi_start);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
|
|
||||||
* have a header that provide this informaiton.
|
|
||||||
*/
|
|
||||||
if (bootm_find_images(image_load_addr, cmd_arg1(argc, argv),
|
|
||||||
cmd_arg2(argc, argv), images->ep,
|
|
||||||
zi_end - zi_start))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
{
|
{
|
||||||
struct bootm_info bmi;
|
struct bootm_info bmi;
|
||||||
@@ -78,17 +28,6 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|||||||
/* Consume 'bootz' */
|
/* Consume 'bootz' */
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
|
|
||||||
if (bootz_start(cmdtp, flag, argc, argv, &images))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We are doing the BOOTM_STATE_LOADOS state ourselves, so must
|
|
||||||
* disable interrupts ourselves
|
|
||||||
*/
|
|
||||||
bootm_disable_interrupts();
|
|
||||||
|
|
||||||
images.os.os = IH_OS_LINUX;
|
|
||||||
|
|
||||||
bootm_init(&bmi);
|
bootm_init(&bmi);
|
||||||
if (argc)
|
if (argc)
|
||||||
bmi.addr_img = argv[0];
|
bmi.addr_img = argv[0];
|
||||||
@@ -99,8 +38,10 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|||||||
bmi.cmd_name = "bootz";
|
bmi.cmd_name = "bootz";
|
||||||
|
|
||||||
ret = bootz_run(&bmi);
|
ret = bootz_run(&bmi);
|
||||||
|
if (ret)
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
U_BOOT_LONGHELP(bootz,
|
U_BOOT_LONGHELP(bootz,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
/*
|
/*
|
||||||
* Copyright 2018 Google, Inc
|
* Copyright 2018 Google, Inc
|
||||||
* Written by Simon Glass <sjg@chromium.org>
|
* Written by Simon Glass <sjg@chromium.org>
|
||||||
|
|||||||
@@ -108,15 +108,8 @@ int ext4fs_get_bgdtable(void)
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
struct ext_filesystem *fs = get_fs();
|
struct ext_filesystem *fs = get_fs();
|
||||||
size_t alloc_size;
|
int gdsize_total = ROUND(fs->no_blkgrp * fs->gdsize, fs->blksz);
|
||||||
int gdsize_total;
|
|
||||||
|
|
||||||
if (__builtin_mul_overflow(fs->no_blkgrp, fs->gdsize, &alloc_size))
|
|
||||||
return -1;
|
|
||||||
gdsize_total = ROUND(alloc_size, fs->blksz);
|
|
||||||
fs->no_blk_pergdt = gdsize_total / fs->blksz;
|
fs->no_blk_pergdt = gdsize_total / fs->blksz;
|
||||||
if (!fs->no_blk_pergdt)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* allocate memory for gdtable */
|
/* allocate memory for gdtable */
|
||||||
fs->gdtable = zalloc(gdsize_total);
|
fs->gdtable = zalloc(gdsize_total);
|
||||||
@@ -124,7 +117,7 @@ int ext4fs_get_bgdtable(void)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
/* read the group descriptor table */
|
/* read the group descriptor table */
|
||||||
status = ext4fs_devread((lbaint_t)fs->gdtable_blkno * fs->sect_perblk,
|
status = ext4fs_devread((lbaint_t)fs->gdtable_blkno * fs->sect_perblk,
|
||||||
0, gdsize_total, fs->gdtable);
|
0, fs->blksz * fs->no_blk_pergdt, fs->gdtable);
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@@ -606,17 +599,10 @@ int ext4fs_init(void)
|
|||||||
int i;
|
int i;
|
||||||
uint32_t real_free_blocks = 0;
|
uint32_t real_free_blocks = 0;
|
||||||
struct ext_filesystem *fs = get_fs();
|
struct ext_filesystem *fs = get_fs();
|
||||||
size_t alloc_size;
|
|
||||||
|
|
||||||
/* check for a reasonable block size, no more than 64K */
|
|
||||||
if (LOG2_BLOCK_SIZE(ext4fs_root) > 16)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
/* populate fs */
|
/* populate fs */
|
||||||
fs->blksz = EXT2_BLOCK_SIZE(ext4fs_root);
|
fs->blksz = EXT2_BLOCK_SIZE(ext4fs_root);
|
||||||
fs->sect_perblk = fs->blksz >> fs->dev_desc->log2blksz;
|
fs->sect_perblk = fs->blksz >> fs->dev_desc->log2blksz;
|
||||||
if (!fs->sect_perblk)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
/* get the superblock */
|
/* get the superblock */
|
||||||
fs->sb = zalloc(SUPERBLOCK_SIZE);
|
fs->sb = zalloc(SUPERBLOCK_SIZE);
|
||||||
@@ -643,9 +629,7 @@ int ext4fs_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* load all the available bitmap block of the partition */
|
/* load all the available bitmap block of the partition */
|
||||||
if (__builtin_mul_overflow(fs->no_blkgrp, sizeof(char *), &alloc_size))
|
fs->blk_bmaps = zalloc(fs->no_blkgrp * sizeof(char *));
|
||||||
goto fail;
|
|
||||||
fs->blk_bmaps = zalloc(alloc_size);
|
|
||||||
if (!fs->blk_bmaps)
|
if (!fs->blk_bmaps)
|
||||||
goto fail;
|
goto fail;
|
||||||
for (i = 0; i < fs->no_blkgrp; i++) {
|
for (i = 0; i < fs->no_blkgrp; i++) {
|
||||||
@@ -665,7 +649,7 @@ int ext4fs_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* load all the available inode bitmap of the partition */
|
/* load all the available inode bitmap of the partition */
|
||||||
fs->inode_bmaps = zalloc(alloc_size);
|
fs->inode_bmaps = zalloc(fs->no_blkgrp * sizeof(unsigned char *));
|
||||||
if (!fs->inode_bmaps)
|
if (!fs->inode_bmaps)
|
||||||
goto fail;
|
goto fail;
|
||||||
for (i = 0; i < fs->no_blkgrp; i++) {
|
for (i = 0; i < fs->no_blkgrp; i++) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause */
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||||
/*
|
/*
|
||||||
* This provides a standard way of passing information between boot phases
|
* This provides a standard way of passing information between boot phases
|
||||||
* (TPL -> SPL -> U-Boot proper.)
|
* (TPL -> SPL -> U-Boot proper.)
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ struct cmd_tbl;
|
|||||||
#define EXT2_BLOCK_SIZE(data) (1 << LOG2_BLOCK_SIZE(data))
|
#define EXT2_BLOCK_SIZE(data) (1 << LOG2_BLOCK_SIZE(data))
|
||||||
|
|
||||||
/* Log2 size of ext2 block in bytes. */
|
/* Log2 size of ext2 block in bytes. */
|
||||||
#define LOG2_BLOCK_SIZE(data) (le32_to_cpu((data)->sblock.log2_block_size) \
|
#define LOG2_BLOCK_SIZE(data) (le32_to_cpu \
|
||||||
|
(data->sblock.log2_block_size) \
|
||||||
+ EXT2_MIN_BLOCK_LOG_SIZE)
|
+ EXT2_MIN_BLOCK_LOG_SIZE)
|
||||||
|
|
||||||
#define EXT2_FT_DIR 2
|
#define EXT2_FT_DIR 2
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
#define __NET_COMMON_H__
|
#define __NET_COMMON_H__
|
||||||
|
|
||||||
#include <asm/cache.h>
|
#include <asm/cache.h>
|
||||||
#include <command.h>
|
|
||||||
#include <env.h>
|
|
||||||
#include <hexdump.h>
|
#include <hexdump.h>
|
||||||
#include <linux/if_ether.h>
|
#include <linux/if_ether.h>
|
||||||
#include <linux/sizes.h>
|
#include <linux/sizes.h>
|
||||||
@@ -13,6 +11,8 @@
|
|||||||
#include <rand.h>
|
#include <rand.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
struct cmd_tbl;
|
||||||
|
|
||||||
#define DEBUG_NET_PKT_TRACE 0 /* Trace all packet data */
|
#define DEBUG_NET_PKT_TRACE 0 /* Trace all packet data */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -463,10 +463,7 @@ int update_tftp(ulong addr, char *interface, char *devstring);
|
|||||||
* 0 to 255
|
* 0 to 255
|
||||||
* Return: IP address, or 0 if invalid
|
* Return: IP address, or 0 if invalid
|
||||||
*/
|
*/
|
||||||
static inline struct in_addr env_get_ip(char *var)
|
struct in_addr env_get_ip(char *var);
|
||||||
{
|
|
||||||
return string_to_ip(env_get(var));
|
|
||||||
}
|
|
||||||
|
|
||||||
int net_init(void);
|
int net_init(void);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
#include <env.h>
|
||||||
#include <net-common.h>
|
#include <net-common.h>
|
||||||
|
|
||||||
void copy_filename(char *dst, const char *src, int size)
|
void copy_filename(char *dst, const char *src, int size)
|
||||||
@@ -25,3 +26,8 @@ int wget_request(ulong dst_addr, char *uri, struct wget_http_info *info)
|
|||||||
wget_info = info ? info : &default_wget_info;
|
wget_info = info ? info : &default_wget_info;
|
||||||
return wget_with_dns(dst_addr, uri);
|
return wget_with_dns(dst_addr, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct in_addr env_get_ip(char *var)
|
||||||
|
{
|
||||||
|
return string_to_ip(env_get(var));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user