diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 28 | ||||
-rw-r--r-- | common/block.c | 35 | ||||
-rw-r--r-- | common/clock.c | 2 | ||||
-rw-r--r-- | common/console_common.c | 2 | ||||
-rw-r--r-- | common/partitions.c | 2 | ||||
-rw-r--r-- | common/startup.c | 29 |
6 files changed, 60 insertions, 38 deletions
diff --git a/common/Kconfig b/common/Kconfig index d1baee60e6..edadcc9f49 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -874,6 +874,13 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW select NET_CMD_IFUP if NET select CMD_IP_ROUTE_GET if NET select CMD_HOST if NET + help + With this option barebox will use the files found under + defaultenv/defaultenv-2-base/ in the source tree as a template for + the defaultenv. The directories specified in DEFAULT_ENVIRONMENT_PATH + will be added to the default environment. If a file is present in + both locations, the file from DEFAULT_ENVIRONMENT_PATH will overwrite + that from the template. config DEFAULT_ENVIRONMENT_GENERIC bool "Generic environment template (old version)" @@ -887,9 +894,12 @@ config DEFAULT_ENVIRONMENT_GENERIC select CMD_CRC_CMP select CMD_GLOBAL help - With this option barebox will use the generic default - environment found under defaultenv/ in the src tree. - The Directory given with DEFAULT_ENVIRONMENT_PATH + Note: this option is not recommended for new boards; use + DEFAULT_ENVIRONMENT_GENERIC_NEW instead. + + With this option barebox will use the old generic default environment + found under defaultenv/defaultenv-1/ in the source tree. + The directory given with DEFAULT_ENVIRONMENT_PATH will be added to the default environment. This should at least contain a /env/config file. This will be able to overwrite the files from defaultenv. @@ -899,12 +909,18 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW_MENU depends on DEFAULT_ENVIRONMENT_GENERIC_NEW depends on CMD_MENUTREE default y + help + Extend the defaultenv template with a menu that is displayed at boot. + The menu files are taken from defaultenv/defaultenv-2-menu/. config DEFAULT_ENVIRONMENT_GENERIC_NEW_DFU bool depends on DEFAULT_ENVIRONMENT_GENERIC_NEW depends on USB_GADGET_DFU default y + help + Extend the defaultenv template with the 'dfu' boot entry, which + allows uploading the kernel and oftree over USB via the dfu protocol. config DEFAULT_ENVIRONMENT_GENERIC_NEW_REBOOT_MODE bool "Generic reboot-mode handlers in the environment" @@ -916,9 +932,9 @@ config DEFAULT_ENVIRONMENT_PATH depends on DEFAULT_ENVIRONMENT prompt "Default environment path" help - Space separated list of paths the default environment will be taken from. - Relative paths will be relative to the barebox Toplevel dir, but absolute - paths are fine as well. + Space separated list of paths from which the default environment will + be taken. Relative paths will be relative to the barebox top-level + directory, but absolute paths are fine as well. config BAREBOXENV_TARGET bool diff --git a/common/block.c b/common/block.c index 6371010a90..1d386edcfd 100644 --- a/common/block.c +++ b/common/block.c @@ -18,7 +18,7 @@ LIST_HEAD(block_device_list); /* a chunk of contiguous data */ struct chunk { void *data; /* data buffer */ - int block_start; /* first block in this chunk */ + sector_t block_start; /* first block in this chunk */ int dirty; /* need to write back to device */ int num; /* number of chunk, debugging only */ struct list_head list; @@ -28,7 +28,7 @@ struct chunk { static int writebuffer_io_len(struct block_device *blk, struct chunk *chunk) { - return min(blk->rdbufsize, blk->num_blocks - chunk->block_start); + return min_t(blkcnt_t, blk->rdbufsize, blk->num_blocks - chunk->block_start); } /* @@ -64,14 +64,14 @@ static int writebuffer_flush(struct block_device *blk) * get the chunk containing a given block. Will return NULL if the * block is not cached, the chunk otherwise. */ -static struct chunk *chunk_get_cached(struct block_device *blk, int block) +static struct chunk *chunk_get_cached(struct block_device *blk, sector_t block) { struct chunk *chunk; list_for_each_entry(chunk, &blk->buffered_blocks, list) { if (block >= chunk->block_start && block < chunk->block_start + blk->rdbufsize) { - dev_dbg(blk->dev, "%s: found %d in %d\n", __func__, + dev_dbg(blk->dev, "%s: found %llu in %d\n", __func__, block, chunk->num); /* * move most recently used entry to the head of the list @@ -88,7 +88,7 @@ static struct chunk *chunk_get_cached(struct block_device *blk, int block) * Get the data pointer for a given block. Will return NULL if * the block is not cached, the data pointer otherwise. */ -static void *block_get_cached(struct block_device *blk, int block) +static void *block_get_cached(struct block_device *blk, sector_t block) { struct chunk *chunk; @@ -135,7 +135,7 @@ static struct chunk *get_chunk(struct block_device *blk) * not cached already. By definition block_get_cached() for * the same block will succeed after this call. */ -static int block_cache(struct block_device *blk, int block) +static int block_cache(struct block_device *blk, sector_t block) { struct chunk *chunk; int ret; @@ -146,7 +146,7 @@ static int block_cache(struct block_device *blk, int block) chunk->block_start = block & ~blk->blkmask; - dev_dbg(blk->dev, "%s: %d to %d\n", __func__, chunk->block_start, + dev_dbg(blk->dev, "%s: %llu to %d\n", __func__, chunk->block_start, chunk->num); if (chunk->block_start * BLOCKSIZE(blk) >= blk->discard_start && @@ -172,7 +172,7 @@ static int block_cache(struct block_device *blk, int block) * Get the data for a block, either from the cache or from * the device. */ -static void *block_get(struct block_device *blk, int block) +static void *block_get(struct block_device *blk, sector_t block) { void *outdata; int ret; @@ -200,9 +200,9 @@ static ssize_t block_op_read(struct cdev *cdev, void *buf, size_t count, { struct block_device *blk = cdev->priv; unsigned long mask = BLOCKSIZE(blk) - 1; - unsigned long block = offset >> blk->blockbits; + sector_t block = offset >> blk->blockbits; size_t icount = count; - int blocks; + blkcnt_t blocks; if (offset & mask) { size_t now = BLOCKSIZE(blk) - (offset & mask); @@ -252,7 +252,7 @@ static ssize_t block_op_read(struct cdev *cdev, void *buf, size_t count, * Put data into a block. This only overwrites the data in the * cache and marks the corresponding chunk as dirty. */ -static int block_put(struct block_device *blk, const void *buf, int block) +static int block_put(struct block_device *blk, const void *buf, sector_t block) { struct chunk *chunk; void *data; @@ -277,9 +277,10 @@ static ssize_t block_op_write(struct cdev *cdev, const void *buf, size_t count, { struct block_device *blk = cdev->priv; unsigned long mask = BLOCKSIZE(blk) - 1; - unsigned long block = offset >> blk->blockbits; + sector_t block = offset >> blk->blockbits; size_t icount = count; - int blocks, ret; + blkcnt_t blocks; + int ret; if (offset & mask) { size_t now = BLOCKSIZE(blk) - (offset & mask); @@ -419,24 +420,24 @@ int blockdevice_unregister(struct block_device *blk) return 0; } -int block_read(struct block_device *blk, void *buf, int block, int num_blocks) +int block_read(struct block_device *blk, void *buf, sector_t block, blkcnt_t num_blocks) { int ret; ret = cdev_read(&blk->cdev, buf, num_blocks << blk->blockbits, - (loff_t)block << blk->blockbits, 0); + block << blk->blockbits, 0); return ret < 0 ? ret : 0; } -int block_write(struct block_device *blk, void *buf, int block, int num_blocks) +int block_write(struct block_device *blk, void *buf, sector_t block, blkcnt_t num_blocks) { int ret; ret = cdev_write(&blk->cdev, buf, num_blocks << blk->blockbits, - (loff_t)block << blk->blockbits, 0); + block << blk->blockbits, 0); return ret < 0 ? ret : 0; } diff --git a/common/clock.c b/common/clock.c index 58c2964b13..7eeba88317 100644 --- a/common/clock.c +++ b/common/clock.c @@ -11,7 +11,7 @@ #include <common.h> #include <init.h> -#include <asm-generic/div64.h> +#include <linux/math64.h> #include <clock.h> #include <poller.h> diff --git a/common/console_common.c b/common/console_common.c index 48590c522c..3e07415723 100644 --- a/common/console_common.c +++ b/common/console_common.c @@ -18,7 +18,7 @@ #include <clock.h> #include <malloc.h> #include <linux/pstore.h> -#include <asm-generic/div64.h> +#include <linux/math64.h> #ifndef CONFIG_CONSOLE_NONE diff --git a/common/partitions.c b/common/partitions.c index 01697f87d0..1f0c544c60 100644 --- a/common/partitions.c +++ b/common/partitions.c @@ -124,7 +124,7 @@ int parse_partition_table(struct block_device *blk) rc = block_read(blk, buf, 0, 2); if (rc != 0) { - dev_err(blk->dev, "Cannot read MBR/partition table\n"); + dev_err(blk->dev, "Cannot read MBR/partition table: %pe\n", ERR_PTR(rc)); goto on_error; } diff --git a/common/startup.c b/common/startup.c index 1ac36d950c..080feebf05 100644 --- a/common/startup.c +++ b/common/startup.c @@ -36,6 +36,7 @@ #include <environment.h> #include <linux/ctype.h> #include <watchdog.h> +#include <glob.h> extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[], __barebox_initcalls_end[]; @@ -298,13 +299,12 @@ postcore_initcall(register_autoboot_vars); static int run_init(void) { - DIR *dir; - struct dirent *d; - const char *initdir = "/env/init"; const char *bmode; bool env_bin_init_exists; enum autoboot_state autoboot; struct stat s; + glob_t g; + int i, ret; setenv("PATH", "/env/bin"); export("PATH"); @@ -326,23 +326,28 @@ static int run_init(void) } /* Run scripts in /env/init/ */ - dir = opendir(initdir); - if (dir) { - char *scr; + ret = glob("/env/init/*", 0, NULL, &g); + if (!ret) { + for (i = 0; i < g.gl_pathc; i++) { + const char *path = g.gl_pathv[i]; + char *scr; + + ret = stat(path, &s); + if (ret) + continue; - while ((d = readdir(dir))) { - if (*d->d_name == '.') + if (!S_ISREG(s.st_mode)) continue; - pr_debug("Executing '%s/%s'...\n", initdir, d->d_name); - scr = basprintf("source %s/%s", initdir, d->d_name); + pr_debug("Executing '%s'...\n", path); + scr = basprintf("source %s", path); run_command(scr); free(scr); } - - closedir(dir); } + globfree(&g); + /* source matching script in /env/bmode/ */ bmode = reboot_mode_get(); if (bmode) { |