* [PATCH 01/10] startup: call a barebox_main function pointer at the end of the startup
2013-01-20 15:35 [PATCH] startup related cleanups Sascha Hauer
@ 2013-01-20 15:35 ` Sascha Hauer
2013-01-20 15:35 ` [PATCH 02/10] move struct action_data to the only file using it Sascha Hauer
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-01-20 15:35 UTC (permalink / raw)
To: barebox
Currently Kconfig dependencies are used to allow non-interactive builds.
This leads to problems in Kconfig getting the dependencies right.
This patch adds a barebox_main function pointer which is called at the
end of the startup process. This defaults to run_shell when a shell is
enabled.
With this the HAVE_NOSHELL Kconfig variable can be removed. Non interactive
builds can now be enabled for every board allowing to compile a binary
without further Kconfig dependencies. This also allows for more flexibility,
for example boards may decide to try non-interactive startup first and
call run_shell if that fails.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-omap/Kconfig | 9 ---------
arch/arm/mach-omap/xload.c | 11 ++++++++++-
common/Kconfig | 8 ++------
common/startup.c | 13 ++++++++++++-
include/common.h | 6 ++++++
5 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index 6611a65..f659184 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -128,7 +128,6 @@ config MACH_OMAP343xSDP
config MACH_BEAGLE
bool "Texas Instrument's Beagle Board"
- select HAVE_NOSHELL
select HAVE_DEFAULT_ENVIRONMENT_NEW
depends on ARCH_OMAP3
help
@@ -137,21 +136,18 @@ config MACH_BEAGLE
config MACH_BEAGLEBONE
bool "Texas Instrument's Beagle Bone"
select OMAP_CLOCK_ALL
- select HAVE_NOSHELL
depends on ARCH_AM33XX
help
Say Y here if you are using Beagle Bone
config MACH_OMAP3EVM
bool "Texas Instrument's OMAP3 EVM"
- select HAVE_NOSHELL
depends on ARCH_OMAP3
help
Say Y here if you are using OMAP3EVM
config MACH_PANDA
bool "Texas Instrument's Panda Board"
- select HAVE_NOSHELL
select MACH_HAS_LOWLEVEL_INIT
select HAVE_DEFAULT_ENVIRONMENT_NEW
depends on ARCH_OMAP4
@@ -160,7 +156,6 @@ config MACH_PANDA
config MACH_ARCHOSG9
bool "Archos G9 tablets"
- select HAVE_NOSHELL
select MACH_HAS_LOWLEVEL_INIT
depends on ARCH_OMAP4
help
@@ -168,7 +163,6 @@ config MACH_ARCHOSG9
config MACH_PCM049
bool "Phytec phyCORE pcm049"
- select HAVE_NOSHELL
depends on ARCH_OMAP4
select MACH_HAS_LOWLEVEL_INIT
help
@@ -177,14 +171,12 @@ config MACH_PCM049
config MACH_PCAAL1
bool "Phytec phyCARD-A-L1"
- select HAVE_NOSHELL
depends on ARCH_OMAP3
help
Say Y here if you are using a phyCARD-A-L1 PCA-A-L1
config MACH_PCAAXL2
bool "Phytec phyCARD XL2"
- select HAVE_NOSHELL
select MACH_HAS_LOWLEVEL_INIT
depends on ARCH_OMAP4
help
@@ -193,7 +185,6 @@ config MACH_PCAAXL2
config MACH_PCM051
bool "Phytec phyCORE pcm051"
select OMAP_CLOCK_ALL
- select HAVE_NOSHELL
select HAVE_DEFAULT_ENVIRONMENT_NEW
depends on ARCH_AM33XX
help
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 47c5d98..41533a9 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -1,6 +1,7 @@
#include <common.h>
#include <partition.h>
#include <nand.h>
+#include <init.h>
#include <driver.h>
#include <linux/mtd/mtd.h>
#include <fs.h>
@@ -171,7 +172,7 @@ enum omap_boot_src omap_bootsrc(void)
/*
* Replaces the default shell in xload configuration
*/
-int run_shell(void)
+static __noreturn int omap_xload(void)
{
int (*func)(void) = NULL;
@@ -211,3 +212,11 @@ int run_shell(void)
while (1);
}
+
+static int omap_set_xload(void)
+{
+ barebox_main = omap_xload;
+
+ return 0;
+}
+late_initcall(omap_set_xload);
diff --git a/common/Kconfig b/common/Kconfig
index b60b78b..9d26abb 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -37,9 +37,6 @@ config BLOCK
config BLOCK_WRITE
bool
-config HAVE_NOSHELL
- bool
-
config FILETYPE
bool
@@ -352,12 +349,11 @@ choice
simple shell. No if/then, no return values from commands, no loops
config SHELL_NONE
- depends on HAVE_NOSHELL
bool "no shell (noninteractive build)"
help
No shell at all. This means no shell is started and your board has
- to provide a run_shell() function which is started at the end of
- the barebox startup process.
+ to overwrite the barebox_main function pointer which is then called
+ at the end of the barebox startup process.
endchoice
config GLOB
diff --git a/common/startup.c b/common/startup.c
index 14409a2..6309f53 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -88,6 +88,8 @@ static int mount_root(void)
fs_initcall(mount_root);
#endif
+int (*barebox_main)(void);
+
void start_barebox (void)
{
initcall_t *initcall;
@@ -96,6 +98,9 @@ void start_barebox (void)
struct stat s;
#endif
+ if (!IS_ENABLED(CONFIG_SHELL_NONE))
+ barebox_main = run_shell;
+
for (initcall = __barebox_initcalls_start;
initcall < __barebox_initcalls_end; initcall++) {
debug("initcall-> %pS\n", *initcall);
@@ -126,9 +131,15 @@ void start_barebox (void)
printf("not found\n");
}
#endif
+
+ if (!barebox_main) {
+ printf("No main function! aborting.\n");
+ hang();
+ }
+
/* main_loop() can return to retry autoboot, if so just run it again. */
for (;;)
- run_shell();
+ barebox_main();
/* NOTREACHED - no way out of command loop except booting */
}
diff --git a/include/common.h b/include/common.h
index b1c96de..e858d0a 100644
--- a/include/common.h
+++ b/include/common.h
@@ -159,6 +159,12 @@ int parse_area_spec(const char *str, loff_t *start, loff_t *size);
unsigned long strtoul_suffix(const char *str, char **endp, int base);
unsigned long long strtoull_suffix(const char *str, char **endp, int base);
+/*
+ * Function pointer to the main barebox function. Defaults
+ * to run_shell() when a shell is enabled.
+ */
+extern int (*barebox_main)(void);
+
void start_barebox(void);
void shutdown_barebox(void);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 02/10] move struct action_data to the only file using it
2013-01-20 15:35 [PATCH] startup related cleanups Sascha Hauer
2013-01-20 15:35 ` [PATCH 01/10] startup: call a barebox_main function pointer at the end of the startup Sascha Hauer
@ 2013-01-20 15:35 ` Sascha Hauer
2013-01-20 15:35 ` [PATCH 03/10] make file_*_action static Sascha Hauer
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-01-20 15:35 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/environment.c | 7 +++++++
include/environment.h | 8 --------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/common/environment.c b/common/environment.c
index e11cd9d..9595986 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -41,6 +41,13 @@
#define EXPORT_SYMBOL(x)
#endif
+struct action_data {
+ int fd;
+ const char *base;
+ void *writep;
+};
+#define PAD4(x) ((x + 3) & ~3)
+
char *default_environment_path = "/dev/env0";
int file_size_action(const char *filename, struct stat *statbuf,
diff --git a/include/environment.h b/include/environment.h
index 096c169..120040e 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -87,14 +87,6 @@ int file_save_action(const char *, struct stat *, void *, int);
int envfs_load(char *filename, char *dirname, unsigned flags);
int envfs_save(char *filename, char *dirname);
-/* This part is used for the host and the target */
-struct action_data {
- int fd;
- const char *base;
- void *writep;
-};
-#define PAD4(x) ((x + 3) & ~3)
-
#endif /* _ENVIRONMENT_H_ */
/**
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 03/10] make file_*_action static
2013-01-20 15:35 [PATCH] startup related cleanups Sascha Hauer
2013-01-20 15:35 ` [PATCH 01/10] startup: call a barebox_main function pointer at the end of the startup Sascha Hauer
2013-01-20 15:35 ` [PATCH 02/10] move struct action_data to the only file using it Sascha Hauer
@ 2013-01-20 15:35 ` Sascha Hauer
2013-01-20 15:35 ` [PATCH 04/10] move prototypes for envfs_* to envfs.h Sascha Hauer
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-01-20 15:35 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/environment.c | 4 ++--
include/environment.h | 4 ----
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/common/environment.c b/common/environment.c
index 9595986..eebccce 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -50,7 +50,7 @@ struct action_data {
char *default_environment_path = "/dev/env0";
-int file_size_action(const char *filename, struct stat *statbuf,
+static int file_size_action(const char *filename, struct stat *statbuf,
void *userdata, int depth)
{
struct action_data *data = userdata;
@@ -75,7 +75,7 @@ int file_size_action(const char *filename, struct stat *statbuf,
return 1;
}
-int file_save_action(const char *filename, struct stat *statbuf,
+static int file_save_action(const char *filename, struct stat *statbuf,
void *userdata, int depth)
{
struct action_data *data = userdata;
diff --git a/include/environment.h b/include/environment.h
index 120040e..65f254b 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -77,10 +77,6 @@ extern char *default_environment_path;
int export(const char *);
-struct stat;
-int file_size_action(const char *, struct stat *, void *, int);
-int file_save_action(const char *, struct stat *, void *, int);
-
#endif /* __BAREBOX__ */
#define ENV_FLAG_NO_OVERWRITE (1 << 0)
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 04/10] move prototypes for envfs_* to envfs.h
2013-01-20 15:35 [PATCH] startup related cleanups Sascha Hauer
` (2 preceding siblings ...)
2013-01-20 15:35 ` [PATCH 03/10] make file_*_action static Sascha Hauer
@ 2013-01-20 15:35 ` Sascha Hauer
2013-01-20 15:35 ` [PATCH 05/10] scripts: remove now unnecessary include Sascha Hauer
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-01-20 15:35 UTC (permalink / raw)
To: barebox
environment.h is for environment variables, not for the environment
storage (envfs), so move the prototypes to envfs.h
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/boards/beaglebone/board.c | 2 +-
arch/arm/boards/panda/board.c | 2 +-
commands/loadenv.c | 2 +-
commands/saveenv.c | 2 +-
common/startup.c | 2 +-
include/envfs.h | 8 +++++++-
include/environment.h | 7 -------
7 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/arch/arm/boards/beaglebone/board.c b/arch/arm/boards/beaglebone/board.c
index f9ac7a4..86de3b0 100644
--- a/arch/arm/boards/beaglebone/board.c
+++ b/arch/arm/boards/beaglebone/board.c
@@ -27,7 +27,7 @@
#include <driver.h>
#include <fs.h>
#include <linux/stat.h>
-#include <environment.h>
+#include <envfs.h>
#include <sizes.h>
#include <io.h>
#include <ns16550.h>
diff --git a/arch/arm/boards/panda/board.c b/arch/arm/boards/panda/board.c
index c5d8fe6..f1fbd5e 100644
--- a/arch/arm/boards/panda/board.c
+++ b/arch/arm/boards/panda/board.c
@@ -19,7 +19,7 @@
#include <sizes.h>
#include <asm/mmu.h>
#include <mach/gpio.h>
-#include <environment.h>
+#include <envfs.h>
#include <mach/xload.h>
#include <i2c/i2c.h>
#include <gpio.h>
diff --git a/commands/loadenv.c b/commands/loadenv.c
index 48284d7..14b9643 100644
--- a/commands/loadenv.c
+++ b/commands/loadenv.c
@@ -23,7 +23,7 @@
#include <common.h>
#include <getopt.h>
#include <command.h>
-#include <environment.h>
+#include <envfs.h>
#include <fs.h>
static int do_loadenv(int argc, char *argv[])
diff --git a/commands/saveenv.c b/commands/saveenv.c
index dd0de7f..7f371a8 100644
--- a/commands/saveenv.c
+++ b/commands/saveenv.c
@@ -25,7 +25,7 @@
#include <errno.h>
#include <fs.h>
#include <fcntl.h>
-#include <environment.h>
+#include <envfs.h>
static int do_saveenv(int argc, char *argv[])
{
diff --git a/common/startup.c b/common/startup.c
index 6309f53..c36bf7c 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -32,7 +32,7 @@
#include <debug_ll.h>
#include <fs.h>
#include <linux/stat.h>
-#include <environment.h>
+#include <envfs.h>
#include <asm/sections.h>
extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[],
diff --git a/include/envfs.h b/include/envfs.h
index 3d14fcb..2db55ed 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -89,5 +89,11 @@ struct envfs_super {
#error "__BYTE_ORDER must be __LITTLE_ENDIAN or __BIG_ENDIAN"
#endif
-#endif /* _ENVFS_H */
+#define ENV_FLAG_NO_OVERWRITE (1 << 0)
+int envfs_load(char *filename, char *dirname, unsigned flags);
+int envfs_save(char *filename, char *dirname);
+
+/* defaults to /dev/env0 */
+extern char *default_environment_path;
+#endif /* _ENVFS_H */
diff --git a/include/environment.h b/include/environment.h
index 65f254b..6500ebb 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -72,17 +72,10 @@ static inline int export(const char *var)
int env_pop_context(void);
int env_push_context(void);
-/* defaults to /dev/env0 */
-extern char *default_environment_path;
-
int export(const char *);
#endif /* __BAREBOX__ */
-#define ENV_FLAG_NO_OVERWRITE (1 << 0)
-int envfs_load(char *filename, char *dirname, unsigned flags);
-int envfs_save(char *filename, char *dirname);
-
#endif /* _ENVIRONMENT_H_ */
/**
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 05/10] scripts: remove now unnecessary include
2013-01-20 15:35 [PATCH] startup related cleanups Sascha Hauer
` (3 preceding siblings ...)
2013-01-20 15:35 ` [PATCH 04/10] move prototypes for envfs_* to envfs.h Sascha Hauer
@ 2013-01-20 15:35 ` Sascha Hauer
2013-01-20 15:35 ` [PATCH 06/10] startup: use IS_ENABLED instead of ifdef Sascha Hauer
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-01-20 15:35 UTC (permalink / raw)
To: barebox
include/environment.h is no longer necessary to build scripts/bareboxenv,
so remove its inclusion.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
include/environment.h | 4 ----
scripts/bareboxenv.c | 1 -
2 files changed, 5 deletions(-)
diff --git a/include/environment.h b/include/environment.h
index 6500ebb..7bdd213 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -20,8 +20,6 @@
#ifndef _ENVIRONMENT_H_
#define _ENVIRONMENT_H_
-
-#ifdef __BAREBOX__
/**
* Managment of a environment variable
*/
@@ -74,8 +72,6 @@ int env_push_context(void);
int export(const char *);
-#endif /* __BAREBOX__ */
-
#endif /* _ENVIRONMENT_H_ */
/**
diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index 707d63d..9284c0b 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -118,7 +118,6 @@ char *concat_subpath_file(const char *path, const char *f)
#include "../include/envfs.h"
#include "../crypto/crc32.c"
#include "../lib/make_directory.c"
-#include "../include/environment.h"
#include "../common/environment.c"
void usage(char *prgname)
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 06/10] startup: use IS_ENABLED instead of ifdef
2013-01-20 15:35 [PATCH] startup related cleanups Sascha Hauer
` (4 preceding siblings ...)
2013-01-20 15:35 ` [PATCH 05/10] scripts: remove now unnecessary include Sascha Hauer
@ 2013-01-20 15:35 ` Sascha Hauer
2013-01-20 15:35 ` [PATCH 07/10] startup: Use IS_ENABLED for loading environment Sascha Hauer
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-01-20 15:35 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/startup.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/common/startup.c b/common/startup.c
index c36bf7c..6513ba5 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -94,9 +94,7 @@ void start_barebox (void)
{
initcall_t *initcall;
int result;
-#ifdef CONFIG_COMMAND_SUPPORT
struct stat s;
-#endif
if (!IS_ENABLED(CONFIG_SHELL_NONE))
barebox_main = run_shell;
@@ -122,15 +120,16 @@ void start_barebox (void)
#endif
}
#endif
-#ifdef CONFIG_COMMAND_SUPPORT
- printf("running /env/bin/init...\n");
- if (!stat("/env/bin/init", &s)) {
- run_command("source /env/bin/init", 0);
- } else {
- printf("not found\n");
+ if (IS_ENABLED(CONFIG_COMMAND_SUPPORT)) {
+ printf("running /env/bin/init...\n");
+
+ if (!stat("/env/bin/init", &s)) {
+ run_command("source /env/bin/init", 0);
+ } else {
+ printf("not found\n");
+ }
}
-#endif
if (!barebox_main) {
printf("No main function! aborting.\n");
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 07/10] startup: Use IS_ENABLED for loading environment
2013-01-20 15:35 [PATCH] startup related cleanups Sascha Hauer
` (5 preceding siblings ...)
2013-01-20 15:35 ` [PATCH 06/10] startup: use IS_ENABLED instead of ifdef Sascha Hauer
@ 2013-01-20 15:35 ` Sascha Hauer
2013-01-20 15:35 ` [PATCH 08/10] startup: add __noreturn to start_barebox Sascha Hauer
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-01-20 15:35 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/startup.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/common/startup.c b/common/startup.c
index 6513ba5..c26bc5f 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -110,16 +110,18 @@ void start_barebox (void)
debug("initcalls done\n");
-#ifdef CONFIG_ENV_HANDLING
- if (envfs_load(default_environment_path, "/env", 0)) {
-#ifdef CONFIG_DEFAULT_ENVIRONMENT
- printf("no valid environment found on %s. "
- "Using default environment\n",
- default_environment_path);
- envfs_load("/dev/defaultenv", "/env", 0);
-#endif
+ if (IS_ENABLED(CONFIG_ENV_HANDLING)) {
+ int ret;
+
+ ret = envfs_load(default_environment_path, "/env", 0);
+
+ if (ret && IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT)) {
+ printf("no valid environment found on %s. "
+ "Using default environment\n",
+ default_environment_path);
+ envfs_load("/dev/defaultenv", "/env", 0);
+ }
}
-#endif
if (IS_ENABLED(CONFIG_COMMAND_SUPPORT)) {
printf("running /env/bin/init...\n");
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 08/10] startup: add __noreturn to start_barebox
2013-01-20 15:35 [PATCH] startup related cleanups Sascha Hauer
` (6 preceding siblings ...)
2013-01-20 15:35 ` [PATCH 07/10] startup: Use IS_ENABLED for loading environment Sascha Hauer
@ 2013-01-20 15:35 ` Sascha Hauer
2013-01-20 15:35 ` [PATCH 09/10] defaultenv loading: rework to use less ifdefs/defines Sascha Hauer
2013-01-20 15:35 ` [PATCH 10/10] filetype: Make buf in file_detect_type const Sascha Hauer
9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-01-20 15:35 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/startup.c | 3 +--
include/common.h | 2 +-
pbl/misc.c | 4 +++-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/common/startup.c b/common/startup.c
index c26bc5f..ecb5691 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -90,7 +90,7 @@ fs_initcall(mount_root);
int (*barebox_main)(void);
-void start_barebox (void)
+void __noreturn start_barebox(void)
{
initcall_t *initcall;
int result;
@@ -162,4 +162,3 @@ void shutdown_barebox(void)
arch_shutdown();
#endif
}
-
diff --git a/include/common.h b/include/common.h
index e858d0a..2c707f7 100644
--- a/include/common.h
+++ b/include/common.h
@@ -165,7 +165,7 @@ unsigned long long strtoull_suffix(const char *str, char **endp, int base);
*/
extern int (*barebox_main)(void);
-void start_barebox(void);
+void __noreturn start_barebox(void);
void shutdown_barebox(void);
/*
diff --git a/pbl/misc.c b/pbl/misc.c
index a2cb44d..9065bf0 100644
--- a/pbl/misc.c
+++ b/pbl/misc.c
@@ -14,6 +14,8 @@ void __noreturn panic(const char *fmt, ...)
while(1);
}
-void start_barebox(void)
+void __noreturn start_barebox(void)
{
+ /* Should never be here in the pbl */
+ hang();
}
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 09/10] defaultenv loading: rework to use less ifdefs/defines
2013-01-20 15:35 [PATCH] startup related cleanups Sascha Hauer
` (7 preceding siblings ...)
2013-01-20 15:35 ` [PATCH 08/10] startup: add __noreturn to start_barebox Sascha Hauer
@ 2013-01-20 15:35 ` Sascha Hauer
2013-01-20 15:35 ` [PATCH 10/10] filetype: Make buf in file_detect_type const Sascha Hauer
9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-01-20 15:35 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/startup.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/common/startup.c b/common/startup.c
index ecb5691..52a8996 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -34,6 +34,7 @@
#include <linux/stat.h>
#include <envfs.h>
#include <asm/sections.h>
+#include <uncompress.h>
extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[],
__barebox_initcalls_end[];
@@ -41,32 +42,35 @@ extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[],
#ifdef CONFIG_DEFAULT_ENVIRONMENT
#include "barebox_default_env.h"
-#ifdef CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED
-#include <uncompress.h>
-void *defaultenv;
-#else
-#define defaultenv default_environment
-#endif
-
static int register_default_env(void)
{
-#ifdef CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED
int ret;
- void *tmp;
+ void *defaultenv;
- tmp = xzalloc(default_environment_size);
- memcpy(tmp, default_environment, default_environment_size);
+ if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED)) {
+ void *tmp = malloc(default_environment_size);
- defaultenv = xzalloc(default_environment_uncompress_size);
+ if (!tmp)
+ return -ENOMEM;
- ret = uncompress(tmp, default_environment_size, NULL, NULL,
- defaultenv, NULL, uncompress_err_stdout);
+ memcpy(tmp, default_environment, default_environment_size);
- free(tmp);
+ defaultenv = xzalloc(default_environment_uncompress_size);
+
+ ret = uncompress(tmp, default_environment_size,
+ NULL, NULL,
+ defaultenv, NULL, uncompress_err_stdout);
+
+ free(tmp);
+
+ if (ret) {
+ free(defaultenv);
+ return ret;
+ }
+ } else {
+ defaultenv = (void *)default_environment;
+ }
- if (ret)
- return ret;
-#endif
add_mem_device("defaultenv", (unsigned long)defaultenv,
default_environment_uncompress_size,
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 10/10] filetype: Make buf in file_detect_type const
2013-01-20 15:35 [PATCH] startup related cleanups Sascha Hauer
` (8 preceding siblings ...)
2013-01-20 15:35 ` [PATCH 09/10] defaultenv loading: rework to use less ifdefs/defines Sascha Hauer
@ 2013-01-20 15:35 ` Sascha Hauer
9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-01-20 15:35 UTC (permalink / raw)
To: barebox
This function has no business changing the buffer.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/filetype.c | 10 +++++-----
include/filetype.h | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/common/filetype.c b/common/filetype.c
index 748e364..5941ad2 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -106,12 +106,12 @@ enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec)
return filetype_mbr;
}
-enum filetype file_detect_type(void *_buf, size_t bufsize)
+enum filetype file_detect_type(const void *_buf, size_t bufsize)
{
- u32 *buf = _buf;
- u64 *buf64 = _buf;
- u8 *buf8 = _buf;
- u16 *buf16 = _buf;
+ const u32 *buf = _buf;
+ const u64 *buf64 = _buf;
+ const u8 *buf8 = _buf;
+ const u16 *buf16 = _buf;
enum filetype type;
if (bufsize < 9)
diff --git a/include/filetype.h b/include/filetype.h
index 91139db..502b920 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -30,7 +30,7 @@ enum filetype {
const char *file_type_to_string(enum filetype f);
const char *file_type_to_short_string(enum filetype f);
-enum filetype file_detect_type(void *_buf, size_t bufsize);
+enum filetype file_detect_type(const void *_buf, size_t bufsize);
enum filetype file_name_detect_type(const char *filename);
enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread