* [PATCH 1/8] env: Make environment variable support optional
2011-04-08 14:56 Size reduction patches Sascha Hauer
@ 2011-04-08 14:56 ` Sascha Hauer
2011-04-08 14:56 ` [PATCH 2/8] make command " Sascha Hauer
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2011-04-08 14:56 UTC (permalink / raw)
To: barebox
Environment variables are only useful in interactive environments.
Make it optional on our way to support a noninteractive barebox.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/Kconfig | 2 ++
common/Kconfig | 5 +++++
common/Makefile | 2 +-
include/environment.h | 12 ++++++++++++
4 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/commands/Kconfig b/commands/Kconfig
index 9d0c72d..a443501 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -29,11 +29,13 @@ config CMD_LOADENV
prompt "loadenv"
config CMD_EXPORT
+ depends on ENVIRONMENT_VARIABLES
tristate
prompt "export"
config CMD_PRINTENV
tristate
+ depends on ENVIRONMENT_VARIABLES
prompt "printenv"
config CMD_READLINE
diff --git a/common/Kconfig b/common/Kconfig
index ac83231..b493a31 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -62,6 +62,9 @@ config LOCALVERSION_AUTO
config BOARDINFO
string
+config ENVIRONMENT_VARIABLES
+ bool "environment variables support"
+
menu "memory layout "
config HAVE_MMU
@@ -219,12 +222,14 @@ choice
config SHELL_HUSH
bool "hush parser"
+ select ENVIRONMENT_VARIABLES
help
Enable hush support. This is the most advanced shell available
for barebox.
config SHELL_SIMPLE
bool "Simple parser"
+ select ENVIRONMENT_VARIABLES
help
simple shell. No if/then, no return values from commands, no loops
endchoice
diff --git a/common/Makefile b/common/Makefile
index 3fc66f4..c8a4332 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -15,7 +15,7 @@ obj-y += command.o
obj-$(CONFIG_CONSOLE_FULL) += console.o
obj-$(CONFIG_CONSOLE_SIMPLE) += console_simple.o
obj-$(CONFIG_DIGEST) += digest.o
-obj-y += env.o
+obj-$(CONFIG_ENVIRONMENT_VARIABLES) += env.o
obj-$(CONFIG_CMD_BOOTM) += image.o
obj-y += startup.o
obj-y += misc.o
diff --git a/include/environment.h b/include/environment.h
index 21a7ffa..1f22fcb 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -44,8 +44,20 @@ struct env_context *get_current_context(void);
char *var_val(struct variable_d *);
char *var_name(struct variable_d *);
+#ifdef CONFIG_ENVIRONMENT_VARIABLES
const char *getenv(const char *);
int setenv(const char *, const char *);
+#else
+static inline char *getenv(const char *var)
+{
+ return NULL;
+}
+
+static inline int setenv(const char *var, const char *val)
+{
+ return 0;
+}
+#endif
int env_pop_context(void);
int env_push_context(void);
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/8] make command support optional
2011-04-08 14:56 Size reduction patches Sascha Hauer
2011-04-08 14:56 ` [PATCH 1/8] env: Make environment variable support optional Sascha Hauer
@ 2011-04-08 14:56 ` Sascha Hauer
2011-04-08 14:56 ` [PATCH 3/8] add noshell support Sascha Hauer
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2011-04-08 14:56 UTC (permalink / raw)
To: barebox
In a noninveractive environment we do not need commands. So make
them optional.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/Kconfig | 11 ++++++++++-
common/Kconfig | 2 ++
common/Makefile | 2 +-
common/startup.c | 5 ++++-
4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/commands/Kconfig b/commands/Kconfig
index a443501..f192d30 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -1,7 +1,14 @@
config REGINFO
bool
-menu "Commands "
+config COMMAND_SUPPORT
+ bool
+ depends on !SHELL_NONE
+ default y
+
+if COMMAND_SUPPORT
+
+menu "commands "
menu "scripting "
@@ -404,3 +411,5 @@ config CMD_USB
The usb command allows to rescan for USB devices.
endmenu
+
+endif
diff --git a/common/Kconfig b/common/Kconfig
index b493a31..83975ee 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -223,6 +223,7 @@ choice
config SHELL_HUSH
bool "hush parser"
select ENVIRONMENT_VARIABLES
+ select COMMAND_SUPPORT
help
Enable hush support. This is the most advanced shell available
for barebox.
@@ -230,6 +231,7 @@ choice
config SHELL_SIMPLE
bool "Simple parser"
select ENVIRONMENT_VARIABLES
+ select COMMAND_SUPPORT
help
simple shell. No if/then, no return values from commands, no loops
endchoice
diff --git a/common/Makefile b/common/Makefile
index c8a4332..6a04460 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -11,7 +11,7 @@ obj-$(CONFIG_BLOCK) += block.o
obj-y += dlmalloc.o
obj-y += clock.o
obj-y += version.o
-obj-y += command.o
+obj-$(CONFIG_COMMAND_SUPPORT) += command.o
obj-$(CONFIG_CONSOLE_FULL) += console.o
obj-$(CONFIG_CONSOLE_SIMPLE) += console_simple.o
obj-$(CONFIG_DIGEST) += digest.o
diff --git a/common/startup.c b/common/startup.c
index b487c5b..3808709 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -118,7 +118,9 @@ void start_barebox (void)
{
initcall_t *initcall;
int result;
+#ifdef CONFIG_COMMAND_SUPPORT
struct stat s;
+#endif
#ifdef CONFIG_HAS_EARLY_INIT
/* We are running from RAM now, copy early initdata from
@@ -150,6 +152,7 @@ void start_barebox (void)
#endif
}
#endif
+#ifdef CONFIG_COMMAND_SUPPORT
printf("running /env/bin/init...\n");
if (!stat("/env/bin/init", &s)) {
@@ -157,7 +160,7 @@ void start_barebox (void)
} else {
printf("not found\n");
}
-
+#endif
/* main_loop() can return to retry autoboot, if so just run it again. */
for (;;)
run_shell();
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/8] add noshell support
2011-04-08 14:56 Size reduction patches Sascha Hauer
2011-04-08 14:56 ` [PATCH 1/8] env: Make environment variable support optional Sascha Hauer
2011-04-08 14:56 ` [PATCH 2/8] make command " Sascha Hauer
@ 2011-04-08 14:56 ` Sascha Hauer
2011-04-08 14:56 ` [PATCH 4/8] arm: compile icache command only when command support is present Sascha Hauer
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2011-04-08 14:56 UTC (permalink / raw)
To: barebox
Some scenarios like initial bootloaders do not need interactive shell
support, so make this optional. Without a shell a board must provide
its own run_shell function.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/Kconfig | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/common/Kconfig b/common/Kconfig
index 83975ee..c3449a9 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -37,6 +37,9 @@ config BLOCK
config BLOCK_WRITE
bool
+config HAVE_NOSHELL
+ bool
+
menu "General Settings "
config LOCALVERSION_AUTO
@@ -234,6 +237,14 @@ choice
select COMMAND_SUPPORT
help
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.
endchoice
config GLOB
@@ -402,7 +413,7 @@ config DEFAULT_ENVIRONMENT
config DEFAULT_ENVIRONMENT_GENERIC
bool
depends on DEFAULT_ENVIRONMENT
- select SHELL_HUSH
+ depends on SHELL_HUSH
select HUSH_GETOPT
select CMD_CRC
select CMD_CRC_CMP
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/8] arm: compile icache command only when command support is present
2011-04-08 14:56 Size reduction patches Sascha Hauer
` (2 preceding siblings ...)
2011-04-08 14:56 ` [PATCH 3/8] add noshell support Sascha Hauer
@ 2011-04-08 14:56 ` Sascha Hauer
2011-04-08 14:56 ` [PATCH 5/8] malloc: put common memory functions to seperate file Sascha Hauer
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2011-04-08 14:56 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/cpu/cpu.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c
index 346f8dc..cf30789 100644
--- a/arch/arm/cpu/cpu.c
+++ b/arch/arm/cpu/cpu.c
@@ -97,7 +97,7 @@ void arch_shutdown(void)
* default setting we are running in barebox, there's no special preparation
* required.
*/
-
+#ifdef CONFIG_COMMAND
static int do_icache(struct command *cmdtp, int argc, char *argv[])
{
if (argc == 1) {
@@ -121,3 +121,4 @@ BAREBOX_CMD_START(icache)
.usage = "show/change icache status",
BAREBOX_CMD_HELP(cmd_icache_help)
BAREBOX_CMD_END
+#endif
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/8] malloc: put common memory functions to seperate file
2011-04-08 14:56 Size reduction patches Sascha Hauer
` (3 preceding siblings ...)
2011-04-08 14:56 ` [PATCH 4/8] arm: compile icache command only when command support is present Sascha Hauer
@ 2011-04-08 14:56 ` Sascha Hauer
2011-04-08 14:56 ` [PATCH 6/8] add dummy_malloc functions Sascha Hauer
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2011-04-08 14:56 UTC (permalink / raw)
To: barebox
These functions are needed independently of the specific
malloc implementation, so move them out.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/Makefile | 1 +
common/dlmalloc.c | 50 -------------------------------------
common/memory.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
include/malloc.h | 1 +
4 files changed, 73 insertions(+), 50 deletions(-)
create mode 100644 common/memory.c
diff --git a/common/Makefile b/common/Makefile
index 6a04460..aa2c222 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_AUTO_COMPLETE) += complete.o
obj-$(CONFIG_POLLER) += poller.o
obj-$(CONFIG_BLOCK) += block.o
+obj-y += memory.o
obj-y += dlmalloc.o
obj-y += clock.o
obj-y += version.o
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index ff63fbe..f9e1828 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -882,56 +882,6 @@ static mbinptr av_[NAV * 2 + 2] = {
/* ----------------------------------------------------------------------- */
-/*
- * Begin and End of memory area for malloc(), and current "brk"
- */
-static ulong malloc_start;
-static ulong malloc_end;
-static ulong malloc_brk;
-
-ulong mem_malloc_start(void)
-{
- return malloc_start;
-}
-
-ulong mem_malloc_end(void)
-{
- return malloc_end;
-}
-
-void mem_malloc_init(void *start, void *end)
-{
- malloc_start = (ulong)start;
- malloc_end = (ulong)end;
- malloc_brk = malloc_start;
-}
-
-static void *sbrk_no_zero(ptrdiff_t increment)
-{
- ulong old = malloc_brk;
- ulong new = old + increment;
-
- if ((new < malloc_start) || (new > malloc_end))
- return NULL;
-
- malloc_brk = new;
-
- return (void *)old;
-}
-
-static void *sbrk(ptrdiff_t increment)
-{
- void *old = sbrk_no_zero(increment);
-
- /* Only clear increment, if valid address was returned */
- if (old != NULL)
- memset(old, 0, increment);
-
- return old;
-}
-
-/* ----------------------------------------------------------------------- */
-
/* Other static bookkeeping data */
/* variables holding tunable values */
diff --git a/common/memory.c b/common/memory.c
new file mode 100644
index 0000000..8f4a768
--- /dev/null
+++ b/common/memory.c
@@ -0,0 +1,71 @@
+/*
+ * memory.c
+ *
+ * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <common.h>
+
+/*
+ * Begin and End of memory area for malloc(), and current "brk"
+ */
+static unsigned long malloc_start;
+static unsigned long malloc_end;
+static unsigned long malloc_brk;
+
+unsigned long mem_malloc_start(void)
+{
+ return malloc_start;
+}
+
+unsigned long mem_malloc_end(void)
+{
+ return malloc_end;
+}
+
+void mem_malloc_init(void *start, void *end)
+{
+ malloc_start = (unsigned long)start;
+ malloc_end = (unsigned long)end;
+ malloc_brk = malloc_start;
+}
+
+static void *sbrk_no_zero(ptrdiff_t increment)
+{
+ unsigned long old = malloc_brk;
+ unsigned long new = old + increment;
+
+ if ((new < malloc_start) || (new > malloc_end))
+ return NULL;
+
+ malloc_brk = new;
+
+ return (void *)old;
+}
+
+void *sbrk(ptrdiff_t increment)
+{
+ void *old = sbrk_no_zero(increment);
+
+ /* Only clear increment, if valid address was returned */
+ if (old != NULL)
+ memset(old, 0, increment);
+
+ return old;
+}
diff --git a/include/malloc.h b/include/malloc.h
index 4b0567e..7b9b062 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -18,6 +18,7 @@ size_t malloc_usable_size(void*);
void malloc_stats(void);
int mallopt(int, int);
struct mallinfo mallinfo(void);
+void *sbrk(ptrdiff_t increment);
#endif
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 6/8] add dummy_malloc functions
2011-04-08 14:56 Size reduction patches Sascha Hauer
` (4 preceding siblings ...)
2011-04-08 14:56 ` [PATCH 5/8] malloc: put common memory functions to seperate file Sascha Hauer
@ 2011-04-08 14:56 ` Sascha Hauer
2011-04-08 14:56 ` [PATCH 7/8] ARM: make exception handling optional Sascha Hauer
2011-04-08 14:56 ` [PATCH 8/8] nand: make reading oob optional Sascha Hauer
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2011-04-08 14:56 UTC (permalink / raw)
To: barebox
For some environments the dummy malloc functions offer a very small
alternative implementation. malloc will get its memory from sbrk()
and never frees memory again.
This of course is not suitable for interactive environments and thus
depends on CONFIG_SHELL_NONE
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/Kconfig | 16 ++++++++++++++++
common/Makefile | 3 ++-
common/dummy_malloc.c | 26 ++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletions(-)
create mode 100644 common/dummy_malloc.c
diff --git a/common/Kconfig b/common/Kconfig
index c3449a9..7d2367b 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -148,6 +148,22 @@ config EXPERIMENTAL
bool
prompt "Prompt for experimental code"
+choice
+ prompt "malloc implementation"
+
+config MALLOC_DLMALLOC
+ bool "dlmalloc"
+
+config MALLOC_DUMMY
+ bool "dummy malloc"
+ depends on SHELL_NONE
+ help
+ select this option to use a dummy malloc implementation. With this
+ memory is never freed. This is suitable for well tested noninteractive
+ environments only.
+
+endchoice
+
config MODULES
depends on HAS_MODULES
depends on EXPERIMENTAL
diff --git a/common/Makefile b/common/Makefile
index aa2c222..9fed2ae 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -9,7 +9,8 @@ obj-$(CONFIG_POLLER) += poller.o
obj-$(CONFIG_BLOCK) += block.o
obj-y += memory.o
-obj-y += dlmalloc.o
+obj-$(CONFIG_MALLOC_DLMALLOC) += dlmalloc.o
+obj-$(CONFIG_MALLOC_DUMMY) += dummy_malloc.o
obj-y += clock.o
obj-y += version.o
obj-$(CONFIG_COMMAND_SUPPORT) += command.o
diff --git a/common/dummy_malloc.c b/common/dummy_malloc.c
new file mode 100644
index 0000000..213e51d
--- /dev/null
+++ b/common/dummy_malloc.c
@@ -0,0 +1,26 @@
+#include <common.h>
+#include <malloc.h>
+
+void *memalign(size_t alignment, size_t bytes)
+{
+ unsigned long mem = (unsigned long)sbrk(bytes + alignment);
+
+ mem = (mem + alignment) & ~(alignment - 1);
+
+ return (void *)mem;
+}
+
+void *malloc(size_t size)
+{
+ return memalign(8, size);
+}
+
+void free(void *ptr)
+{
+}
+
+void *realloc(void *ptr, size_t size)
+{
+ BUG();
+}
+
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 7/8] ARM: make exception handling optional
2011-04-08 14:56 Size reduction patches Sascha Hauer
` (5 preceding siblings ...)
2011-04-08 14:56 ` [PATCH 6/8] add dummy_malloc functions Sascha Hauer
@ 2011-04-08 14:56 ` Sascha Hauer
2011-04-08 14:56 ` [PATCH 8/8] nand: make reading oob optional Sascha Hauer
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2011-04-08 14:56 UTC (permalink / raw)
To: barebox
On several boards without MMU support the vectors cannot be mapped
to 0x0 and exception support is nonfunctional anyway, so make this
configurable.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/Kconfig | 5 +++++
arch/arm/cpu/Makefile | 4 ++--
arch/arm/cpu/start.c | 10 ++++++++++
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4392620..6b2b400 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -120,9 +120,14 @@ config ARM_OPTIMZED_STRING_FUNCTIONS
These functions work much faster than the normal versions but
increase your binary size.
+config ARM_EXCEPTIONS
+ bool "enable arm exception handling support"
+ default y
+
config ARM_UNWIND
bool "enable stack unwinding support"
depends on AEABI
+ depends on ARM_EXCEPTIONS
help
This option enables stack unwinding support in barebox
using the information automatically generated by the
diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index 036768e..e30ae1c 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -1,6 +1,6 @@
obj-y += cpu.o
-obj-y += exceptions.o
-obj-y += interrupts.o
+obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
+obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
obj-y += start.o
#
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index ddb65e8..ff6bea2 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -31,6 +31,7 @@ void __naked __section(.text_entry) exception_vectors(void)
{
__asm__ __volatile__ (
"b reset\n" /* reset */
+#ifdef CONFIG_ARM_EXCEPTIONS
"ldr pc, =undefined_instruction\n" /* undefined instruction */
"ldr pc, =software_interrupt\n" /* software interrupt (SWI) */
"ldr pc, =prefetch_abort\n" /* prefetch abort */
@@ -38,6 +39,15 @@ void __naked __section(.text_entry) exception_vectors(void)
"ldr pc, =not_used\n" /* (reserved) */
"ldr pc, =irq\n" /* irq (interrupt) */
"ldr pc, =fiq\n" /* fiq (fast interrupt) */
+#else
+ "1: bne 1b\n" /* undefined instruction */
+ "1: bne 1b\n" /* software interrupt (SWI) */
+ "1: bne 1b\n" /* prefetch abort */
+ "1: bne 1b\n" /* data abort */
+ "1: bne 1b\n" /* (reserved) */
+ "1: bne 1b\n" /* irq (interrupt) */
+ "1: bne 1b\n" /* fiq (fast interrupt) */
+#endif
".word 0x65726162\n" /* 'BARE' */
".word 0x00786f62\n" /* 'BOX' */
".word _text\n" /* text base. If copied there,
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 8/8] nand: make reading oob optional
2011-04-08 14:56 Size reduction patches Sascha Hauer
` (6 preceding siblings ...)
2011-04-08 14:56 ` [PATCH 7/8] ARM: make exception handling optional Sascha Hauer
@ 2011-04-08 14:56 ` Sascha Hauer
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2011-04-08 14:56 UTC (permalink / raw)
To: barebox
The nand oob functions occupy quite some binary space. If not needed,
we can save this space by making this configurable.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/nand/Kconfig | 5 ++++
drivers/mtd/nand/nand.c | 42 +++++++++++++++++++++++++++++++++-------
drivers/mtd/nand/nand_base.c | 9 +++++++-
drivers/mtd/nand/nand_hwecc.c | 2 +
4 files changed, 49 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 331aac8..126f7cc 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -49,6 +49,11 @@ config NAND_BBT
Say y here to include support for bad block tables. This speeds
up the process of checking for bad blocks
+config NAND_READ_OOB
+ bool
+ default y
+ prompt "create a device for reading the OOB data"
+
config NAND_IMX
bool
prompt "i.MX NAND driver"
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
index 2333160..deb9400 100644
--- a/drivers/mtd/nand/nand.c
+++ b/drivers/mtd/nand/nand.c
@@ -184,6 +184,7 @@ static struct file_operations nand_ops = {
.lseek = dev_lseek_default,
};
+#ifdef CONFIG_NAND_READ_OOB
static ssize_t nand_read_oob(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags)
{
struct mtd_info *info = cdev->priv;
@@ -215,9 +216,39 @@ static struct file_operations nand_ops_oob = {
.lseek = dev_lseek_default,
};
-int add_mtd_device(struct mtd_info *mtd)
+static int nand_init_oob_cdev(struct mtd_info *mtd)
{
struct nand_chip *chip = mtd->priv;
+
+ mtd->cdev_oob.ops = &nand_ops_oob;
+ mtd->cdev_oob.size = (mtd->size >> chip->page_shift) * mtd->oobsize;
+ mtd->cdev_oob.name = asprintf("nand_oob%d", mtd->class_dev.id);
+ mtd->cdev_oob.priv = mtd;
+ mtd->cdev_oob.dev = &mtd->class_dev;
+ devfs_create(&mtd->cdev_oob);
+
+ return 0;
+}
+
+static void nand_exit_oob_cdev(struct mtd_info *mtd)
+{
+ free(mtd->cdev_oob.name);
+}
+#else
+
+static int nand_init_oob_cdev(struct mtd_info *mtd)
+{
+ return 0;
+}
+
+static void nand_exit_oob_cdev(struct mtd_info *mtd)
+{
+ return;
+}
+#endif
+
+int add_mtd_device(struct mtd_info *mtd)
+{
char str[16];
strcpy(mtd->class_dev.name, "nand");
@@ -235,12 +266,7 @@ int add_mtd_device(struct mtd_info *mtd)
devfs_create(&mtd->cdev);
- mtd->cdev_oob.ops = &nand_ops_oob;
- mtd->cdev_oob.size = (mtd->size >> chip->page_shift) * mtd->oobsize;
- mtd->cdev_oob.name = asprintf("nand_oob%d", mtd->class_dev.id);
- mtd->cdev_oob.priv = mtd;
- mtd->cdev_oob.dev = &mtd->class_dev;
- devfs_create(&mtd->cdev_oob);
+ nand_init_oob_cdev(mtd);
return 0;
}
@@ -248,7 +274,7 @@ int add_mtd_device(struct mtd_info *mtd)
int del_mtd_device (struct mtd_info *mtd)
{
unregister_device(&mtd->class_dev);
- free(mtd->cdev_oob.name);
+ nand_exit_oob_cdev(mtd);
free(mtd->param_size.value);
free(mtd->cdev.name);
return 0;
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index f641f8d..d627f16 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -601,6 +601,7 @@ static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
* @ops: oob ops structure
* @len: size of oob to transfer
*/
+#ifdef CONFIG_NAND_READ_OOB
static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
struct mtd_oob_ops *ops, size_t len)
{
@@ -641,6 +642,7 @@ static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
}
return NULL;
}
+#endif
/**
* nand_do_read_ops - [Internal] Read data with ECC
@@ -706,6 +708,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
buf += bytes;
+#ifdef CONFIG_NAND_READ_OOB
if (unlikely(oob)) {
/* Raw mode does data:oob:data:oob */
if (ops->mode != MTD_OOB_RAW) {
@@ -720,7 +723,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
buf = nand_transfer_oob(chip,
buf, ops, mtd->oobsize);
}
-
+#endif
if (!(chip->options & NAND_NO_READRDY)) {
/*
* Apply delay or wait for ready/busy pin. Do
@@ -836,6 +839,7 @@ int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
*
* NAND read out-of-band data from the spare area
*/
+#ifdef CONFIG_NAND_READ_OOB
static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops)
{
@@ -961,6 +965,7 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from,
out:
return ret;
}
+#endif
/**
* nand_block_isbad - [MTD Interface] Check if block at offset is bad
@@ -1420,7 +1425,9 @@ int nand_scan_tail(struct mtd_info *mtd)
mtd->write_oob = nand_write_oob;
#endif
mtd->read = nand_read;
+#ifdef CONFIG_NAND_READ_OOB
mtd->read_oob = nand_read_oob;
+#endif
mtd->lock = NULL;
mtd->unlock = NULL;
mtd->block_isbad = nand_block_isbad;
diff --git a/drivers/mtd/nand/nand_hwecc.c b/drivers/mtd/nand/nand_hwecc.c
index e5de30a..95b08d3 100644
--- a/drivers/mtd/nand/nand_hwecc.c
+++ b/drivers/mtd/nand/nand_hwecc.c
@@ -90,8 +90,10 @@ void nand_init_ecc_hw(struct nand_chip *chip)
/* Use standard hwecc read page function ? */
if (!chip->ecc.read_page)
chip->ecc.read_page = nand_read_page_hwecc;
+#ifdef CONFIG_NAND_READ_OOB
if (!chip->ecc.read_oob)
chip->ecc.read_oob = nand_read_oob_std;
+#endif
#ifdef CONFIG_NAND_WRITE
if (!chip->ecc.write_oob)
chip->ecc.write_oob = nand_write_oob_std;
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread