9
0
Fork 0

Merge branch 'work/magicvars' into next

This commit is contained in:
Sascha Hauer 2011-11-29 20:52:03 +01:00
commit 7631e76c0b
16 changed files with 122 additions and 1 deletions

View File

@ -80,6 +80,10 @@ SECTIONS
.barebox_cmd : { BAREBOX_CMDS }
__barebox_cmd_end = .;
__barebox_magicvar_start = .;
.barebox_magicvar : { BAREBOX_MAGICVARS }
__barebox_magicvar_end = .;
__barebox_initcalls_start = .;
.barebox_initcalls : { INITCALLS }
__barebox_initcalls_end = .;

View File

@ -18,6 +18,7 @@
#include <common.h>
#include <environment.h>
#include <init.h>
#include <magicvar.h>
#include <io.h>
#include <mach/imx-regs.h>
@ -88,4 +89,6 @@ static int imx_25_35_boot_save_loc(void)
coredevice_initcall(imx_25_35_boot_save_loc);
BAREBOX_MAGICVAR(barebox_loc, "The source barebox has been booted from");
#endif

View File

@ -71,6 +71,10 @@ SECTIONS
.barebox_cmd : { BAREBOX_CMDS }
___barebox_cmd_end = .;
__barebox_magicvar_start = .;
.barebox_magicvar : { BAREBOX_MAGICVARS }
__barebox_magicvar_end = .;
___barebox_initcalls_start = .;
.barebox_initcalls : { INITCALLS }
___barebox_initcalls_end = .;

View File

@ -56,6 +56,10 @@ SECTIONS
.barebox_cmd : { BAREBOX_CMDS }
__barebox_cmd_end = .;
__barebox_magicvar_start = .;
.barebox_magicvar : { BAREBOX_MAGICVARS }
__barebox_magicvar_end = .;
__barebox_initcalls_start = .;
.barebox_initcalls : { INITCALLS }
__barebox_initcalls_end = .;

View File

@ -56,6 +56,10 @@ SECTIONS
.barebox_cmd : { BAREBOX_CMDS }
__barebox_cmd_end = .;
__barebox_magicvar_start = .;
.barebox_magicvar : { BAREBOX_MAGICVARS }
__barebox_magicvar_end = .;
__barebox_initcalls_start = .;
.barebox_initcalls : { INITCALLS }
__barebox_initcalls_end = .;

View File

@ -102,6 +102,10 @@ SECTIONS
.barebox_cmd : { BAREBOX_CMDS }
__barebox_cmd_end = .;
__barebox_magicvar_start = .;
.barebox_magicvar : { BAREBOX_MAGICVARS }
__barebox_magicvar_end = .;
__barebox_initcalls_start = .;
.barebox_initcalls : { INITCALLS }
__barebox_initcalls_end = .;

View File

@ -7,6 +7,11 @@ SECTIONS
__barebox_initcalls : { INITCALLS }
__barebox_initcalls_end = .;
. = ALIGN(64);
__barebox_magicvar_start = .;
.barebox_magicvar : { BAREBOX_MAGICVARS }
__barebox_magicvar_end = .;
. = ALIGN(64);
__barebox_cmd_start = .;
__barebox_cmd : { BAREBOX_CMDS }

View File

@ -170,7 +170,14 @@ SECTIONS
. = ALIGN(4);
} > barebox
.barebox_initcalls : AT ( LOADADDR(.barebox_cmd) + SIZEOF (.barebox_cmd) ) {
.barebox_magicvars : AT ( LOADADDR(.barebox_cmd) + SIZEOF (.barebox_cmd) ) {
__barebox_magicvar_start = .;
.barebox_magicvar : { BAREBOX_MAGICVARS }
__barebox_magicvar_end = .;
. = ALIGN(4);
} > barebox
.barebox_initcalls : AT ( LOADADDR(.barebox_magicvars) + SIZEOF (.barebox_magicvars) ) {
__barebox_initcalls_start = .;
INITCALLS
__barebox_initcalls_end = .;

View File

@ -383,6 +383,20 @@ config CMD_HELP
default y
prompt "help"
config CMD_MAGICVAR
tristate
prompt "magicvar"
help
barebox has some shell variables with special meanings. This
command shows the available magic variables.
config CMD_MAGICVAR_HELP
bool
prompt "display description"
depends on CMD_MAGICVAR
help
Also display a description to the magic variables
config CMD_DEVINFO
tristate
default y

View File

@ -58,3 +58,4 @@ obj-$(CONFIG_CMD_LED_TRIGGER) += trigger.o
obj-$(CONFIG_CMD_USB) += usb.o
obj-$(CONFIG_CMD_TIME) += time.o
obj-$(CONFIG_CMD_OFTREE) += oftree.o
obj-$(CONFIG_CMD_MAGICVAR) += magicvar.o

View File

@ -42,6 +42,7 @@
#include <boot.h>
#include <rtc.h>
#include <init.h>
#include <magicvar.h>
#include <asm-generic/memory_layout.h>
/*
@ -365,6 +366,8 @@ BAREBOX_CMD_START(bootm)
BAREBOX_CMD_HELP(cmd_bootm_help)
BAREBOX_CMD_END
BAREBOX_MAGICVAR(bootargs, "Linux Kernel parameters");
/**
* @page bootm_command

20
commands/magicvar.c Normal file
View File

@ -0,0 +1,20 @@
#include <common.h>
#include <command.h>
#include <magicvar.h>
static int do_magicvar(struct command *cmdtp, int argc, char *argv[])
{
struct magicvar *m;
for (m = &__barebox_magicvar_start;
m != &__barebox_magicvar_end;
m++)
printf("%-32s %s\n", m->name, m->description);
return 0;
}
BAREBOX_CMD_START(magicvar)
.cmd = do_magicvar,
.usage = "List information about magic variables",
BAREBOX_CMD_END

View File

@ -122,6 +122,7 @@
#include <glob.h>
#include <getopt.h>
#include <libbb.h>
#include <magicvar.h>
#include <linux/list.h>
/*cmd_boot.c*/
@ -540,6 +541,8 @@ static int builtin_getopt(struct p_context *ctx, struct child_prog *child)
return 0;
}
BAREBOX_MAGICVAR(OPTARG, "optarg for hush builtin getopt");
#endif
/* run_pipe_real() starts all the jobs, but doesn't wait for anything
@ -1721,6 +1724,11 @@ BAREBOX_CMD_START(getopt)
BAREBOX_CMD_END
#endif
BAREBOX_MAGICVAR(PATH, "colon seperated list of pathes to search for executables");
#ifdef CONFIG_HUSH_FANCY_PROMPT
BAREBOX_MAGICVAR(PS1, "hush prompt");
#endif
/**
* @file
* @brief A prototype Bourne shell grammar parser

View File

@ -24,3 +24,5 @@
#define BAREBOX_CMDS KEEP(*(SORT_BY_NAME(.barebox_cmd*)))
#define BAREBOX_SYMS KEEP(*(__usymtab))
#define BAREBOX_MAGICVARS KEEP(*(SORT_BY_NAME(.barebox_magicvar*)))

32
include/magicvar.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef __MAGIC_VARS_H
#define __MAGIC_VARS_H
#include <linux/stringify.h>
struct magicvar {
const char *name;
const char *description;
};
extern struct magicvar __barebox_magicvar_start;
extern struct magicvar __barebox_magicvar_end;
#ifdef CONFIG_CMD_MAGICVAR_HELP
#define MAGICVAR_DESCRIPTION(d) (d)
#else
#define MAGICVAR_DESCRIPTION(d) NULL
#endif
#ifdef CONFIG_CMD_MAGICVAR
#define BAREBOX_MAGICVAR(_name, _description) \
extern const struct magicvar __barebox_magicvar_##_name; \
const struct magicvar __barebox_magicvar_##_name \
__attribute__ ((unused,section (".barebox_magicvar_" __stringify(_name)))) = { \
.name = #_name, \
.description = MAGICVAR_DESCRIPTION(_description), \
};
#else
#define BAREBOX_MAGICVAR(_name, _description)
#endif
#endif /* __MAGIC_VARS_H */

View File

@ -15,6 +15,7 @@
#include <net.h>
#include <libbb.h>
#include <errno.h>
#include <magicvar.h>
#include <linux/err.h>
#define OPT_SIZE 312 /* Minimum DHCP Options size per RFC2131 - results in 576 byte pkt */
@ -482,3 +483,8 @@ BAREBOX_CMD_START(dhcp)
.usage = "invoke dhcp client to obtain ip/boot params",
BAREBOX_CMD_END
BAREBOX_MAGICVAR(bootfile, "bootfile returned from DHCP request");
BAREBOX_MAGICVAR(nameserver, "Nameserver returned from DHCP request");
BAREBOX_MAGICVAR(hostname, "hostname returned from DHCP request");
BAREBOX_MAGICVAR(domainname, "domainname returned from DHCP request");
BAREBOX_MAGICVAR(rootpath, "rootpath returned from DHCP request");