diff options
Diffstat (limited to 'commands')
63 files changed, 207 insertions, 455 deletions
diff --git a/commands/Kconfig b/commands/Kconfig index f2756cc400..8767807408 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -468,7 +468,17 @@ config CMD_OFTREE tristate select OFTREE prompt "oftree" - select FDT + help + The oftree command has support for dumping devicetrees and, if + enabled, to probe devices from the devicetree + +config CMD_OFTREE_PROBE + bool + depends on CMD_OFTREE + select OFDEVICE + prompt "oftree probe support" + help + This enables the -p option to probe devices from the devicetree endmenu @@ -535,10 +545,11 @@ config CMD_LSMOD depends on MODULES prompt "lsmod" -config CMD_BMP +config CMD_SPLASH bool depends on VIDEO - prompt "bmp" + select IMAGE_RENDERER + prompt "splash" help show bmp files on framebuffer devices diff --git a/commands/Makefile b/commands/Makefile index ccebd7f559..24bf46a80e 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -49,7 +49,7 @@ obj-$(CONFIG_CMD_VERSION) += version.o obj-$(CONFIG_CMD_HELP) += help.o obj-$(CONFIG_CMD_LSMOD) += lsmod.o obj-$(CONFIG_CMD_INSMOD) += insmod.o -obj-$(CONFIG_CMD_BMP) += bmp.o +obj-$(CONFIG_CMD_SPLASH) += splash.o obj-$(CONFIG_USB_GADGET_DFU) += dfu.o obj-$(CONFIG_USB_GADGET_SERIAL) += usbserial.o obj-$(CONFIG_CMD_GPIO) += gpio.o diff --git a/commands/automount.c b/commands/automount.c index aa1e417664..4f7aa0e01e 100644 --- a/commands/automount.c +++ b/commands/automount.c @@ -14,10 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation. */ #include <common.h> #include <command.h> diff --git a/commands/bmp.c b/commands/bmp.c deleted file mode 100644 index 4130474931..0000000000 --- a/commands/bmp.c +++ /dev/null @@ -1,221 +0,0 @@ -#include <common.h> -#include <command.h> -#include <fs.h> -#include <linux/stat.h> -#include <errno.h> -#include <malloc.h> -#include <getopt.h> -#include <fcntl.h> -#include <fb.h> -#include <bmp_layout.h> -#include <asm/byteorder.h> - -static inline void set_pixel(struct fb_info *info, void *adr, int r, int g, int b) -{ - u32 px; - - px = (r >> (8 - info->red.length)) << info->red.offset | - (g >> (8 - info->green.length)) << info->green.offset | - (b >> (8 - info->blue.length)) << info->blue.offset; - - switch (info->bits_per_pixel) { - case 8: - break; - case 16: - *(u16 *)adr = px; - break; - case 32: - *(u32 *)adr = px; - break; - } -} - -static int do_bmp(int argc, char *argv[]) -{ - int ret, opt, fd; - char *fbdev = "/dev/fb0"; - void *fb, *offscreenbuf = NULL; - struct fb_info info; - struct bmp_image *bmp; - char *bmpfile; - int bmpsize; - char *image; - int sw, sh, width, height, startx = -1, starty = -1; - int bits_per_pixel, fbsize; - int xres, yres; - int offscreen = 0; - void *adr, *buf; - - while((opt = getopt(argc, argv, "f:x:y:o")) > 0) { - switch(opt) { - case 'f': - fbdev = optarg; - break; - case 'x': - startx = simple_strtoul(optarg, NULL, 0); - break; - case 'y': - starty = simple_strtoul(optarg, NULL, 0); - case 'o': - offscreen = 1; - } - } - - if (optind == argc) { - printf("no filename given\n"); - return 1; - } - bmpfile = argv[optind]; - - fd = open(fbdev, O_RDWR); - if (fd < 0) { - perror("open"); - return 1; - } - - fb = memmap(fd, PROT_READ | PROT_WRITE); - if (fb == (void *)-1) { - perror("memmap"); - goto failed_memmap; - } - - ret = ioctl(fd, FBIOGET_SCREENINFO, &info); - if (ret) { - perror("ioctl"); - goto failed_memmap; - } - - xres = info.xres; - yres = info.yres; - - bmp = read_file(bmpfile, &bmpsize); - if (!bmp) { - printf("unable to read %s\n", bmpfile); - goto failed_memmap; - } - - if (bmp->header.signature[0] != 'B' || - bmp->header.signature[1] != 'M') { - printf("No valid bmp file\n"); - } - - sw = le32_to_cpu(bmp->header.width); - sh = le32_to_cpu(bmp->header.height); - - if (startx < 0) { - startx = (xres - sw) / 2; - if (startx < 0) - startx = 0; - } - - if (starty < 0) { - starty = (yres - sh) / 2; - if (starty < 0) - starty = 0; - } - - width = min(sw, xres - startx); - height = min(sh, yres - starty); - - bits_per_pixel = le16_to_cpu(bmp->header.bit_count); - fbsize = xres * yres * (info.bits_per_pixel >> 3); - - if (offscreen) { - /* Don't fail if malloc fails, just continue rendering directly - * on the framebuffer - */ - offscreenbuf = malloc(fbsize); - if (offscreenbuf) - memcpy(offscreenbuf, fb, fbsize); - } - - buf = offscreenbuf ? offscreenbuf : fb; - - if (bits_per_pixel == 8) { - int x, y; - struct bmp_color_table_entry *color_table = bmp->color_table; - - for (y = 0; y < height; y++) { - image = (char *)bmp + - le32_to_cpu(bmp->header.data_offset); - image += (sh - y - 1) * sw * (bits_per_pixel >> 3); - adr = buf + ((y + starty) * xres + startx) * - (info.bits_per_pixel >> 3); - for (x = 0; x < width; x++) { - int pixel; - - pixel = *image; - - set_pixel(&info, adr, color_table[pixel].red, - color_table[pixel].green, - color_table[pixel].blue); - adr += info.bits_per_pixel >> 3; - - image += bits_per_pixel >> 3; - } - } - } else if (bits_per_pixel == 24) { - int x, y; - - for (y = 0; y < height; y++) { - image = (char *)bmp + - le32_to_cpu(bmp->header.data_offset); - image += (sh - y - 1) * sw * (bits_per_pixel >> 3); - adr = buf + ((y + starty) * xres + startx) * - (info.bits_per_pixel >> 3); - for (x = 0; x < width; x++) { - char *pixel; - - pixel = image; - - set_pixel(&info, adr, pixel[2], pixel[1], - pixel[0]); - adr += info.bits_per_pixel >> 3; - - image += bits_per_pixel >> 3; - } - } - } else - printf("bmp: illegal bits per pixel value: %d\n", bits_per_pixel); - - if (offscreenbuf) { - memcpy(fb, offscreenbuf, fbsize); - free(offscreenbuf); - } - - free(bmp); - close(fd); - - return 0; - -failed_memmap: - close(fd); - - return 1; -} - -BAREBOX_CMD_HELP_START(bmp) -BAREBOX_CMD_HELP_USAGE("bmp [OPTIONS] FILE\n") -BAREBOX_CMD_HELP_SHORT("Show the bitmap FILE on the framebuffer.\n") -BAREBOX_CMD_HELP_OPT ("-f <fb>", "framebuffer device (/dev/fb0)\n") -BAREBOX_CMD_HELP_OPT ("-x <xofs>", "x offset (default center)\n") -BAREBOX_CMD_HELP_OPT ("-y <yofs>", "y offset (default center)\n") -BAREBOX_CMD_HELP_OPT ("-o", "render offscreen\n") -BAREBOX_CMD_HELP_END - -/** - * @page bmp_command - -This command displays a graphics in the bitmap (.bmp) format on the -framebuffer. Currently the bmp command supports images with 8 and 24 bit -color depth. - -\todo What does the -o (offscreen) option do? - - */ - -BAREBOX_CMD_START(bmp) - .cmd = do_bmp, - .usage = "show a bmp image", - BAREBOX_CMD_HELP(cmd_bmp_help) -BAREBOX_CMD_END diff --git a/commands/bootm.c b/commands/bootm.c index 2d9f7f2dc7..8e51695d94 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -15,10 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ /* diff --git a/commands/cat.c b/commands/cat.c index d65a024628..1c112fc46b 100644 --- a/commands/cat.c +++ b/commands/cat.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/cd.c b/commands/cd.c index ab5c417ce6..936fec84f6 100644 --- a/commands/cd.c +++ b/commands/cd.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/clear.c b/commands/clear.c index 28b4da9661..e6d553d9dc 100644 --- a/commands/clear.c +++ b/commands/clear.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/cp.c b/commands/cp.c index a0434cbe9b..45f08d8c35 100644 --- a/commands/cp.c +++ b/commands/cp.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/crc.c b/commands/crc.c index 8f80e424fd..a0071b0e8b 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/dfu.c b/commands/dfu.c index eab65e519a..af6573acf8 100644 --- a/commands/dfu.c +++ b/commands/dfu.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/digest.c b/commands/digest.c index c077ad9892..c9bb1320be 100644 --- a/commands/digest.c +++ b/commands/digest.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/echo.c b/commands/echo.c index a19d99292f..8929234aab 100644 --- a/commands/echo.c +++ b/commands/echo.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> @@ -33,10 +30,9 @@ static int do_echo(int argc, char *argv[]) int fd = stdout, opt, newline = 1; char *file = NULL; int oflags = O_WRONLY | O_CREAT; -#ifdef CONFIG_CMD_ECHO_E char str[CONFIG_CBSIZE]; int process_escape = 0; -#endif + /* We can't use getopt() here because we want to * echo all things we don't understand. */ @@ -66,11 +62,9 @@ static int do_echo(int argc, char *argv[]) goto no_optarg_out; optind++; break; -#ifdef CONFIG_CMD_ECHO_E case 'e': - process_escape = 1; + process_escape = IS_ENABLED(CONFIG_CMD_ECHO_E); break; -#endif default: goto exit_parse; } @@ -89,13 +83,12 @@ exit_parse: for (i = optind; i < argc; i++) { if (i > optind) fputc(fd, ' '); -#ifdef CONFIG_CMD_ECHO_E if (process_escape) { process_escape_sequence(argv[i], str, CONFIG_CBSIZE); fputs(fd, str); - } else -#endif + } else { fputs(fd, argv[i]); + } } if (newline) diff --git a/commands/edit.c b/commands/edit.c index eddec0b935..295d0a709e 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/exec.c b/commands/exec.c index e2509ff475..bd7d54afd2 100644 --- a/commands/exec.c +++ b/commands/exec.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/export.c b/commands/export.c index ebf7723568..c6196e0c4f 100644 --- a/commands/export.c +++ b/commands/export.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/false.c b/commands/false.c index 1642f8de15..60d6989c4b 100644 --- a/commands/false.c +++ b/commands/false.c @@ -15,10 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/flash.c b/commands/flash.c index d71349a192..b1673de61f 100644 --- a/commands/flash.c +++ b/commands/flash.c @@ -17,10 +17,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ /** diff --git a/commands/global.c b/commands/global.c index de6b13e7bd..427a231a9e 100644 --- a/commands/global.c +++ b/commands/global.c @@ -15,48 +15,74 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <malloc.h> #include <command.h> #include <globalvar.h> #include <environment.h> +#include <getopt.h> -static int do_global(int argc, char *argv[]) +static int globalvar_set(char* name, char* value) { int ret; + + ret = globalvar_add_simple(name); + + if (value) { + char *tmp = asprintf("global.%s", name); + ret = setenv(tmp, value); + free(tmp); + } + + return ret ? 1 : 0; +} + +static int do_global(int argc, char *argv[]) +{ + int opt; + int do_set_match = 0; char *value; - if (argc != 2) + while ((opt = getopt(argc, argv, "r")) > 0) { + switch (opt) { + case 'r': + do_set_match = 1; + break; + } + } + + argc -= optind; + argv += optind; + + if (argc != 1) return COMMAND_ERROR_USAGE; - value = strchr(argv[1], '='); + value = strchr(argv[0], '='); if (value) { *value = 0; value++; } - ret = globalvar_add_simple(argv[1]); + if (do_set_match) { + if (!value) + value = ""; - if (value) { - char *name = asprintf("global.%s", argv[1]); - ret = setenv(name, value); - free(name); + globalvar_set_match(argv[0], value); + return 0; } - return ret ? 1 : 0; + return globalvar_set(argv[0], value); } BAREBOX_CMD_HELP_START(global) -BAREBOX_CMD_HELP_USAGE("global <var>[=<value]\n") +BAREBOX_CMD_HELP_USAGE("global [-r] <var>[=<value]\n") BAREBOX_CMD_HELP_SHORT("add a new global variable named <var>, optionally set to <value>\n") +BAREBOX_CMD_HELP_SHORT("-r to set a value to of all globalvars beginning with 'match'") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(global) .cmd = do_global, - .usage = "create global variables", + .usage = "create or set global variables", BAREBOX_CMD_HELP(cmd_global_help) BAREBOX_CMD_END diff --git a/commands/go.c b/commands/go.c index 14569a52e5..2e7bc1e7be 100644 --- a/commands/go.c +++ b/commands/go.c @@ -17,10 +17,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/gpio.c b/commands/gpio.c index fe37665750..a91e6e0294 100644 --- a/commands/gpio.c +++ b/commands/gpio.c @@ -9,10 +9,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/help.c b/commands/help.c index d7d9ba25af..72b0befecb 100644 --- a/commands/help.c +++ b/commands/help.c @@ -15,10 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/i2c.c b/commands/i2c.c index 763db8a1ab..8370b43dab 100644 --- a/commands/i2c.c +++ b/commands/i2c.c @@ -13,10 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/iomem.c b/commands/iomem.c index c22878c1c8..e117c2a9f6 100644 --- a/commands/iomem.c +++ b/commands/iomem.c @@ -14,10 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation. */ #include <common.h> #include <command.h> diff --git a/commands/led.c b/commands/led.c index 14fb2aa356..a4f117bff4 100644 --- a/commands/led.c +++ b/commands/led.c @@ -16,10 +16,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/linux16.c b/commands/linux16.c index 5ed3a8b917..30fa2de7df 100644 --- a/commands/linux16.c +++ b/commands/linux16.c @@ -16,10 +16,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA * */ diff --git a/commands/linux_exec.c b/commands/linux_exec.c index 201d7a1a8b..ef00ee780b 100644 --- a/commands/linux_exec.c +++ b/commands/linux_exec.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/loadb.c b/commands/loadb.c index 50f323e856..898b9e337d 100644 --- a/commands/loadb.c +++ b/commands/loadb.c @@ -24,10 +24,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ /* diff --git a/commands/loadenv.c b/commands/loadenv.c index 99ad542bc2..5bf17406b2 100644 --- a/commands/loadenv.c +++ b/commands/loadenv.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/loads.c b/commands/loads.c index 1727be7275..7f4c647526 100644 --- a/commands/loads.c +++ b/commands/loads.c @@ -15,10 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ /* diff --git a/commands/login.c b/commands/login.c index 0b5f3cbb4a..fb6bb35cfc 100644 --- a/commands/login.c +++ b/commands/login.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/ls.c b/commands/ls.c index d36ef578c9..1fdb24406d 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/mem.c b/commands/mem.c index ec46a48ef5..441b7f25d1 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -13,10 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * MA 02111-1307 USA */ /* diff --git a/commands/meminfo.c b/commands/meminfo.c index 1d24cfdb3c..6e1e8c3672 100644 --- a/commands/meminfo.c +++ b/commands/meminfo.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/memtest.c b/commands/memtest.c index 651a195a05..2d64d00a99 100644 --- a/commands/memtest.c +++ b/commands/memtest.c @@ -17,10 +17,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/menu.c b/commands/menu.c index 8833d749b1..9b96942a3f 100644 --- a/commands/menu.c +++ b/commands/menu.c @@ -14,10 +14,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/mkdir.c b/commands/mkdir.c index 65013699ed..55df379372 100644 --- a/commands/mkdir.c +++ b/commands/mkdir.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/mount.c b/commands/mount.c index 5b12ad4d96..0628a60a50 100644 --- a/commands/mount.c +++ b/commands/mount.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/nand.c b/commands/nand.c index 6124daea01..f000142f99 100644 --- a/commands/nand.c +++ b/commands/nand.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/nandtest.c b/commands/nandtest.c index 06b7f94519..d683b24165 100644 --- a/commands/nandtest.c +++ b/commands/nandtest.c @@ -10,9 +10,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/net.c b/commands/net.c index e77f12fce6..49ffeccf4b 100644 --- a/commands/net.c +++ b/commands/net.c @@ -15,10 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ /** diff --git a/commands/oftree.c b/commands/oftree.c index 77afbc5a19..7404db56b1 100644 --- a/commands/oftree.c +++ b/commands/oftree.c @@ -21,9 +21,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> @@ -48,7 +45,8 @@ static int do_oftree(int argc, char *argv[]) char *file = NULL; const char *node = "/"; int dump = 0; - int parse = 0; + int probe = 0; + int ret; while ((opt = getopt(argc, argv, "dpfn:")) > 0) { switch (opt) { @@ -56,7 +54,12 @@ static int do_oftree(int argc, char *argv[]) dump = 1; break; case 'p': - parse = 1; + if (IS_ENABLED(CONFIG_CMD_OFTREE_PROBE)) { + probe = 1; + } else { + printf("oftree device probe support disabled\n"); + return COMMAND_ERROR_USAGE; + } break; case 'f': free(barebox_fdt); @@ -71,7 +74,7 @@ static int do_oftree(int argc, char *argv[]) if (optind < argc) file = argv[optind]; - if (!dump && !parse) + if (!dump && !probe) return COMMAND_ERROR_USAGE; if (dump) { @@ -95,7 +98,7 @@ static int do_oftree(int argc, char *argv[]) return 0; } - if (parse) { + if (probe) { if (!file) return COMMAND_ERROR_USAGE; @@ -105,17 +108,13 @@ static int do_oftree(int argc, char *argv[]) return 1; } - fdt = xrealloc(fdt, size + 0x8000); - fdt_open_into(fdt, fdt, size + 0x8000); - if (!fdt) { - printf("unable to read %s\n", file); + ret = of_parse_dtb(fdt); + if (ret) { + printf("parse oftree: %s\n", strerror(-ret)); return 1; } - if (barebox_fdt) - free(barebox_fdt); - - barebox_fdt = fdt; + of_probe(); } return 0; @@ -123,7 +122,7 @@ static int do_oftree(int argc, char *argv[]) BAREBOX_CMD_HELP_START(oftree) BAREBOX_CMD_HELP_USAGE("oftree [OPTIONS]\n") -BAREBOX_CMD_HELP_OPT ("-p <FILE>", "parse and store oftree from <file>\n") +BAREBOX_CMD_HELP_OPT ("-p <FILE>", "probe devices in oftree from <file>\n") BAREBOX_CMD_HELP_OPT ("-d [FILE]", "dump oftree from [FILE] or the parsed tree if no file is given\n") BAREBOX_CMD_HELP_OPT ("-f", "free stored oftree\n") BAREBOX_CMD_HELP_END diff --git a/commands/partition.c b/commands/partition.c index 4c3f30c257..fdd6041227 100644 --- a/commands/partition.c +++ b/commands/partition.c @@ -16,9 +16,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/passwd.c b/commands/passwd.c index 7f704ad454..baccfa6c0c 100644 --- a/commands/passwd.c +++ b/commands/passwd.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/printenv.c b/commands/printenv.c index 071a2d36de..b18c7a137e 100644 --- a/commands/printenv.c +++ b/commands/printenv.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/pwd.c b/commands/pwd.c index d68a509f78..6fe4cf390a 100644 --- a/commands/pwd.c +++ b/commands/pwd.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/readline.c b/commands/readline.c index d1ce7ea271..60670fa675 100644 --- a/commands/readline.c +++ b/commands/readline.c @@ -15,10 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/reginfo.c b/commands/reginfo.c index a31013a664..f5bc8a09ba 100644 --- a/commands/reginfo.c +++ b/commands/reginfo.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/reset.c b/commands/reset.c index 97d04eed13..835926b270 100644 --- a/commands/reset.c +++ b/commands/reset.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/rm.c b/commands/rm.c index ab8bca80cc..4e765acf7a 100644 --- a/commands/rm.c +++ b/commands/rm.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/saveenv.c b/commands/saveenv.c index 549fcd4279..dd0de7f75b 100644 --- a/commands/saveenv.c +++ b/commands/saveenv.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/setenv.c b/commands/setenv.c index 4bcdd51619..57ba71e041 100644 --- a/commands/setenv.c +++ b/commands/setenv.c @@ -13,9 +13,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** diff --git a/commands/sleep.c b/commands/sleep.c index 950ec08743..2574804c17 100644 --- a/commands/sleep.c +++ b/commands/sleep.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/splash.c b/commands/splash.c new file mode 100644 index 0000000000..f40e3e1ec7 --- /dev/null +++ b/commands/splash.c @@ -0,0 +1,133 @@ +#include <common.h> +#include <command.h> +#include <fs.h> +#include <linux/stat.h> +#include <errno.h> +#include <malloc.h> +#include <getopt.h> +#include <fcntl.h> +#include <fb.h> +#include <image_renderer.h> +#include <graphic_utils.h> + +static int do_splash(int argc, char *argv[]) +{ + int ret, opt, fd; + char *fbdev = "/dev/fb0"; + void *fb; + struct fb_info info; + char *image_file; + int startx = -1, starty = -1; + int xres, yres; + int offscreen = 0; + u32 bg_color = 0x00000000; + bool do_bg = false; + void *offscreenbuf = NULL; + + while((opt = getopt(argc, argv, "f:x:y:ob:")) > 0) { + switch(opt) { + case 'f': + fbdev = optarg; + break; + case 'b': + bg_color = simple_strtoul(optarg, NULL, 0); + do_bg = true; + break; + case 'x': + startx = simple_strtoul(optarg, NULL, 0); + break; + case 'y': + starty = simple_strtoul(optarg, NULL, 0); + case 'o': + offscreen = 1; + } + } + + if (optind == argc) { + printf("no filename given\n"); + return 1; + } + image_file = argv[optind]; + + fd = open(fbdev, O_RDWR); + if (fd < 0) { + perror("open"); + return 1; + } + + fb = memmap(fd, PROT_READ | PROT_WRITE); + if (fb == (void *)-1) { + perror("memmap"); + goto failed_memmap; + } + + ret = ioctl(fd, FBIOGET_SCREENINFO, &info); + if (ret) { + perror("ioctl"); + goto failed_memmap; + } + + xres = info.xres; + yres = info.yres; + + if (offscreen) { + int fbsize; + /* Don't fail if malloc fails, just continue rendering directly + * on the framebuffer + */ + + fbsize = xres * yres * (info.bits_per_pixel >> 3); + offscreenbuf = malloc(fbsize); + if (offscreenbuf) { + if (do_bg) + memset_pixel(&info, offscreenbuf, bg_color, xres * yres); + else + memcpy(offscreenbuf, fb, fbsize); + } + } else if (do_bg) { + memset_pixel(&info, fb, bg_color, xres * yres); + } + + if (image_renderer_file(&info, image_file, fb, startx, starty, + offscreenbuf) < 0) + ret = 1; + + if (offscreenbuf) + free(offscreenbuf); + + close(fd); + + return ret; + +failed_memmap: + close(fd); + + return 1; +} + +BAREBOX_CMD_HELP_START(splash) +BAREBOX_CMD_HELP_USAGE("splash [OPTIONS] FILE\n") +BAREBOX_CMD_HELP_SHORT("Show the bitmap FILE on the framebuffer.\n") +BAREBOX_CMD_HELP_OPT ("-f <fb>", "framebuffer device (/dev/fb0)\n") +BAREBOX_CMD_HELP_OPT ("-x <xofs>", "x offset (default center)\n") +BAREBOX_CMD_HELP_OPT ("-y <yofs>", "y offset (default center)\n") +BAREBOX_CMD_HELP_OPT ("-b <color>", "background color in 0xttrrggbb\n") +BAREBOX_CMD_HELP_OPT ("-o", "render offscreen\n") +BAREBOX_CMD_HELP_END + +/** + * @page bmp_command + +This command displays a graphics in the bitmap (.bmp) format on the +framebuffer. Currently the bmp command supports images with 8 and 24 bit +color depth. + +\todo What does the -o (offscreen) option do? + + */ + +BAREBOX_CMD_START(splash) + .cmd = do_splash, + .usage = "show a bmp image", + BAREBOX_CMD_HELP(cmd_splash_help) +BAREBOX_CMD_END diff --git a/commands/test.c b/commands/test.c index 18eeaab8c1..b3cd164f61 100644 --- a/commands/test.c +++ b/commands/test.c @@ -18,9 +18,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/timeout.c b/commands/timeout.c index d4e90cd897..feb27f52af 100644 --- a/commands/timeout.c +++ b/commands/timeout.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/trigger.c b/commands/trigger.c index 1d2dec146b..85f16b00bb 100644 --- a/commands/trigger.c +++ b/commands/trigger.c @@ -16,10 +16,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/true.c b/commands/true.c index e50152ff57..a09776bcd2 100644 --- a/commands/true.c +++ b/commands/true.c @@ -15,10 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> diff --git a/commands/umount.c b/commands/umount.c index 9731cfc9d4..e6de1bc8ff 100644 --- a/commands/umount.c +++ b/commands/umount.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/uncompress.c b/commands/uncompress.c index 179d525749..58c8c9600b 100644 --- a/commands/uncompress.c +++ b/commands/uncompress.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> diff --git a/commands/usb.c b/commands/usb.c index 729a40257c..e5030659b4 100644 --- a/commands/usb.c +++ b/commands/usb.c @@ -15,9 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/usbserial.c b/commands/usbserial.c index 380bee091a..a884a28d27 100644 --- a/commands/usbserial.c +++ b/commands/usbserial.c @@ -17,9 +17,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <common.h> #include <command.h> diff --git a/commands/version.c b/commands/version.c index 6dbda7aade..6578fdd9cf 100644 --- a/commands/version.c +++ b/commands/version.c @@ -15,10 +15,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA */ #include <common.h> |