diff options
Diffstat (limited to 'common')
| -rw-r--r-- | common/board_f.c | 15 | ||||
| -rw-r--r-- | common/cmd_sandbox.c | 64 | ||||
| -rw-r--r-- | common/console.c | 16 | 
3 files changed, 86 insertions, 9 deletions
| diff --git a/common/board_f.c b/common/board_f.c index fcfd713b0..c2f47bc18 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -347,9 +347,10 @@ done:  #ifdef CONFIG_SANDBOX  static int setup_ram_buf(void)  { -	gd->arch.ram_buf = os_malloc(CONFIG_SYS_SDRAM_SIZE); -	assert(gd->arch.ram_buf); -	gd->ram_size = CONFIG_SYS_SDRAM_SIZE; +	struct sandbox_state *state = state_get_current(); + +	gd->arch.ram_buf = state->ram_buf; +	gd->ram_size = state->ram_size;  	return 0;  } @@ -772,7 +773,7 @@ static int setup_reloc(void)  }  /* ARM calls relocate_code from its crt0.S */ -#if !defined(CONFIG_ARM) +#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)  static int jump_to_copy(void)  { @@ -792,8 +793,6 @@ static int jump_to_copy(void)  	 * (CPU cache)  	 */  	board_init_f_r_trampoline(gd->start_addr_sp); -#elif defined(CONFIG_SANDBOX) -	board_init_r(gd->new_gd, 0);  #else  	relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr);  #endif @@ -995,7 +994,7 @@ static init_fnc_t init_sequence_f[] = {  	INIT_FUNC_WATCHDOG_RESET  	reloc_fdt,  	setup_reloc, -#ifndef CONFIG_ARM +#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)  	jump_to_copy,  #endif  	NULL, @@ -1015,7 +1014,7 @@ void board_init_f(ulong boot_flags)  	if (initcall_run_list(init_sequence_f))  		hang(); -#ifndef CONFIG_ARM +#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)  	/* NOTREACHED - jump_to_copy() does not return */  	hang();  #endif diff --git a/common/cmd_sandbox.c b/common/cmd_sandbox.c index 8d59364b6..00982b164 100644 --- a/common/cmd_sandbox.c +++ b/common/cmd_sandbox.c @@ -6,6 +6,9 @@  #include <common.h>  #include <fs.h> +#include <part.h> +#include <sandboxblockdev.h> +#include <asm/errno.h>  static int do_sandbox_load(cmd_tbl_t *cmdtp, int flag, int argc,  			   char * const argv[]) @@ -25,10 +28,69 @@ static int do_sandbox_save(cmd_tbl_t *cmdtp, int flag, int argc,  	return do_save(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);  } +static int do_sandbox_bind(cmd_tbl_t *cmdtp, int flag, int argc, +			   char * const argv[]) +{ +	if (argc < 2 || argc > 3) +		return CMD_RET_USAGE; +	char *ep; +	char *dev_str = argv[1]; +	char *file = argc >= 3 ? argv[2] : NULL; +	int dev = simple_strtoul(dev_str, &ep, 16); +	if (*ep) { +		printf("** Bad device specification %s **\n", dev_str); +		return CMD_RET_USAGE; +	} +	return host_dev_bind(dev, file); +} + +static int do_sandbox_info(cmd_tbl_t *cmdtp, int flag, int argc, +			   char * const argv[]) +{ +	if (argc < 1 || argc > 2) +		return CMD_RET_USAGE; +	int min_dev = 0; +	int max_dev = CONFIG_HOST_MAX_DEVICES - 1; +	if (argc >= 2) { +		char *ep; +		char *dev_str = argv[1]; +		int dev = simple_strtoul(dev_str, &ep, 16); +		if (*ep) { +			printf("** Bad device specification %s **\n", dev_str); +			return CMD_RET_USAGE; +		} +		min_dev = dev; +		max_dev = dev; +	} +	int dev; +	printf("%3s %12s %s\n", "dev", "blocks", "path"); +	for (dev = min_dev; dev <= max_dev; dev++) { +		block_dev_desc_t *blk_dev; +		int ret; + +		printf("%3d ", dev); +		ret = host_get_dev_err(dev, &blk_dev); +		if (ret) { +			if (ret == -ENOENT) +				puts("Not bound to a backing file\n"); +			else if (ret == -ENODEV) +				puts("Invalid host device number\n"); + +			continue; +		} +		struct host_block_dev *host_dev = blk_dev->priv; +		printf("%12lu %s\n", (unsigned long)blk_dev->lba, +		       host_dev->filename); +	} +	return 0; +} +  static cmd_tbl_t cmd_sandbox_sub[] = {  	U_BOOT_CMD_MKENT(load, 7, 0, do_sandbox_load, "", ""),  	U_BOOT_CMD_MKENT(ls, 3, 0, do_sandbox_ls, "", ""),  	U_BOOT_CMD_MKENT(save, 6, 0, do_sandbox_save, "", ""), +	U_BOOT_CMD_MKENT(bind, 3, 0, do_sandbox_bind, "", ""), +	U_BOOT_CMD_MKENT(info, 3, 0, do_sandbox_info, "", ""),  };  static int do_sandbox(cmd_tbl_t *cmdtp, int flag, int argc, @@ -57,4 +119,6 @@ U_BOOT_CMD(  	"sb ls host <filename>                      - list files on host\n"  	"sb save host <dev> <filename> <addr> <bytes> [<offset>] - "  		"save a file to host\n" +	"sb bind <dev> [<filename>] - bind \"host\" device to file\n" +	"sb info [<dev>]            - show device binding & info"  ); diff --git a/common/console.c b/common/console.c index cc55068c7..2dfb78888 100644 --- a/common/console.c +++ b/common/console.c @@ -8,6 +8,7 @@  #include <common.h>  #include <stdarg.h>  #include <malloc.h> +#include <os.h>  #include <serial.h>  #include <stdio_dev.h>  #include <exports.h> @@ -415,6 +416,12 @@ static inline void print_pre_console_buffer(void) {}  void putc(const char c)  { +#ifdef CONFIG_SANDBOX +	if (!gd) { +		os_putc(c); +		return; +	} +#endif  #ifdef CONFIG_SILENT_CONSOLE  	if (gd->flags & GD_FLG_SILENT)  		return; @@ -439,6 +446,13 @@ void putc(const char c)  void puts(const char *s)  { +#ifdef CONFIG_SANDBOX +	if (!gd) { +		os_puts(s); +		return; +	} +#endif +  #ifdef CONFIG_SILENT_CONSOLE  	if (gd->flags & GD_FLG_SILENT)  		return; @@ -467,7 +481,7 @@ int printf(const char *fmt, ...)  	uint i;  	char printbuffer[CONFIG_SYS_PBSIZE]; -#ifndef CONFIG_PRE_CONSOLE_BUFFER +#if !defined(CONFIG_SANDBOX) && !defined(CONFIG_PRE_CONSOLE_BUFFER)  	if (!gd->have_console)  		return 0;  #endif |