Re: [PATCH 1/2] mtd: nand: Fix compiler warning

2013-03-06 Thread Sascha Hauer
On Tue, Mar 05, 2013 at 07:09:01PM +0400, Alexander Shiyan wrote:
 This patch fixes following warning:
 drivers/mtd/nand/nand_write.c: In function 'nand_do_write_ops':
 drivers/mtd/nand/nand_write.c:272: warning: 'ret' may be used uninitialized 
 in this function
 
 Signed-off-by: Alexander Shiyan shc_w...@mail.ru

Applied, thanks

 ---
  drivers/mtd/nand/nand_write.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/mtd/nand/nand_write.c b/drivers/mtd/nand/nand_write.c
 index eea5113..0e2f98f 100644
 --- a/drivers/mtd/nand/nand_write.c
 +++ b/drivers/mtd/nand/nand_write.c
 @@ -269,7 +269,7 @@ int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
   uint32_t writelen = ops-len;
   uint8_t *oob = ops-oobbuf;
   uint8_t *buf = ops-datbuf;
 - int ret, subpage;
 + int ret = 0, subpage;
  
   ops-retlen = 0;
   if (!writelen)
 -- 
 1.7.12.4
 
 
 ___
 barebox mailing list
 barebox@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/barebox
 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 1/1] devfs: add symlink support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
On 08:43 Wed 06 Mar , Sascha Hauer wrote:
 On Sat, Feb 16, 2013 at 12:35:53PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
 wrote:
  Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
  ---
   fs/devfs.c   |   70 
  ++
   include/driver.h |1 +
   2 files changed, 71 insertions(+)
 
 What's your usecase with this patch? Telling me could increase my
 motivation applying it.
I use it to handle boot device and tty today

so the application part does not care about the real hardware they always have
the same device (file) to search
 
 One thing I see with this patch that the next thing would be to add
 directory support to debugfs in which case we might be better off
 adding real device nodes and remove the devfs like we have it now
 completely.
yeah I've the idea to rewrite the devfs completly and the ramfs too

as the ramfs should be at vfs level so the devfs will nearly implement nothing

Best Regards,
J.
 
 Sascha
 
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 1/1] devfs: add symlink support

2013-03-06 Thread Sascha Hauer
On Wed, Mar 06, 2013 at 09:01:18AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 On 08:43 Wed 06 Mar , Sascha Hauer wrote:
  On Sat, Feb 16, 2013 at 12:35:53PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
  wrote:
   Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
   ---
fs/devfs.c   |   70 
   ++
include/driver.h |1 +
2 files changed, 71 insertions(+)
  
  What's your usecase with this patch? Telling me could increase my
  motivation applying it.
 I use it to handle boot device and tty today
 
 so the application part does not care about the real hardware they always have
 the same device (file) to search

This is in the same league as I wanted to do with persistent device
names. We should think about this in a more general way.

  
  One thing I see with this patch that the next thing would be to add
  directory support to debugfs in which case we might be better off
  adding real device nodes and remove the devfs like we have it now
  completely.
 yeah I've the idea to rewrite the devfs completly and the ramfs too
 
 as the ramfs should be at vfs level so the devfs will nearly implement nothing

vfs level? You would have to implement one first, we do not have a vfs
level at all ;)

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 0/9 v3] introduction of dmesg support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
HI,

v3: add more swtich

we currently have 2 fifo at comsole level one for input one for output
we fill the output fifo before any console is registered and then
empty it

Now we introduce a new mecanism as in the kernel dmesg

we will always fill the dmesg kfifo with drivers output

as in barebox we have 2 world

device/drivers and applicaiotn (commands)

the verbositty of the printk can be selected at runtime and
compilation

so for now on drivers will have to use pr_xxx and dev_xxx and
application will use printf

dmesg will print the kfifo at any time

we will extend this later with more control of what the drivers output
on the console or just in the fifo

This new feature is optionnal if dmes is disable we continue as before

The following changes since commit 94e71b843f6456abacc2fe76a5c375a461fabdf7:

  libubi: Use global mtd_all_ff function (2013-03-04 10:54:46 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/dmesg

for you to fetch changes up to 564196ff6ca3e17652d4d78e0c7523771221919e:

  barebox_banner: switch to pr_info (2013-03-04 19:28:05 +0800)


Jean-Christophe PLAGNIOL-VILLARD (9):
  kfifo: introduce kfifo_dump_str to dump the fifo
  console: switch to kfifo_dump_str
  intoduce dmesg to print the barebox printk to dmesg ring buffer
  startup: switch to pr_xxx
  at91: clock switch to pr_info
  meminfo: switch to pr_xxx
  net/console: switch to pr_xxx
  startup: switch to pr_xxx
  barebox_banner: switch to pr_info

 arch/arm/mach-at91/clock.c  |2 +-
 commands/Kconfig|   19 +++
 common/console.c|  127 
---
 common/meminfo.c|6 +++---
 common/startup.c|   12 ++--
 common/version.c|4 ++--
 drivers/base/driver.c   |   18 --
 include/kfifo.h |2 ++
 include/linux/barebox-wrapper.h |   11 ---
 include/printk.h|   68 

 lib/kfifo.c |   21 +
 net/netconsole.c|4 ++--
 12 files changed, 240 insertions(+), 54 deletions(-)

Best Regards,
J.

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 4/9] startup: switch to pr_xxx

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/startup.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index 52a8996..e49cc4c 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -105,14 +105,14 @@ void __noreturn start_barebox(void)
 
for (initcall = __barebox_initcalls_start;
initcall  __barebox_initcalls_end; initcall++) {
-   debug(initcall- %pS\n, *initcall);
+   pr_debug(initcall- %pS\n, *initcall);
result = (*initcall)();
if (result)
pr_err(initcall %pS failed: %s\n, *initcall,
strerror(-result));
}
 
-   debug(initcalls done\n);
+   pr_debug(initcalls done\n);
 
if (IS_ENABLED(CONFIG_ENV_HANDLING)) {
int ret;
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/9] kfifo: introduce kfifo_dump_str to dump the fifo

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to implement a dmesg mecanism in barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 include/kfifo.h |2 ++
 lib/kfifo.c |   21 +
 2 files changed, 23 insertions(+)

diff --git a/include/kfifo.h b/include/kfifo.h
index 25880f4..9dbbe0d 100644
--- a/include/kfifo.h
+++ b/include/kfifo.h
@@ -74,5 +74,7 @@ static inline unsigned int kfifo_len(struct kfifo *fifo)
 void kfifo_putc(struct kfifo *fifo, unsigned char c);
 unsigned int kfifo_getc(struct kfifo *fifo, unsigned char *c);
 
+void kfifo_dump_str(struct kfifo *fifo, void (*dump)(unsigned char c));
+
 #endif
 
diff --git a/lib/kfifo.c b/lib/kfifo.c
index afd3894..7892aed 100644
--- a/lib/kfifo.c
+++ b/lib/kfifo.c
@@ -154,3 +154,24 @@ unsigned int kfifo_getc(struct kfifo *fifo, unsigned char 
*c)
return 0;
 }
 
+void kfifo_dump_str(struct kfifo *fifo, void (*dump)(unsigned char c))
+{
+   int i;
+   unsigned char *c;
+   unsigned int l;
+   unsigned int len;
+
+   len = fifo-in - fifo-out;
+
+   /* first get the data from fifo-out until the end of the buffer */
+   l = min(len, fifo-size - (fifo-out  (fifo-size - 1)));
+   c = fifo-buffer + (fifo-out  (fifo-size - 1));
+   for (i = 0; i  l; i++)
+   dump(c[i]);
+
+   /* then get the rest (if any) from the beginning of the buffer */
+   c = fifo-buffer;
+   l = len - l;
+   for (i = 0; i  l; i++)
+   dump(c[i]);
+}
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 9/9] barebox_banner: switch to pr_info

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/version.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/version.c b/common/version.c
index 22e111a..d33f4d0 100644
--- a/common/version.c
+++ b/common/version.c
@@ -16,6 +16,6 @@ void barebox_banner (void)
if (!board)
board = CONFIG_BOARDINFO;
 
-   printf(\n\n%s\n\n, version_string);
-   printf(Board: %s\n, board);
+   pr_info(\n\n%s\n\n, version_string);
+   pr_info(Board: %s\n, board);
 }
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 5/9] at91: clock switch to pr_info

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 arch/arm/mach-at91/clock.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index 2dde632..296f5d5 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -756,7 +756,7 @@ static int at91_clock_display(void)
if (pll_overclock)
pr_info(Clocks: PLLA overclocked, %ld MHz\n, plla.rate_hz / 
100);
 
-   printf(Clocks: CPU %u MHz, master %u MHz, main %u.%03u MHz\n,
+   pr_info(Clocks: CPU %u MHz, master %u MHz, main %u.%03u MHz\n,
cpu_freq / 100, (unsigned) mck.rate_hz / 100,
(unsigned) main_clk.rate_hz / 100,
((unsigned) main_clk.rate_hz % 100) / 1000);
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 7/9] net/console: switch to pr_xxx

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 net/netconsole.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netconsole.c b/net/netconsole.c
index 7d0f3f4..8db8356 100644
--- a/net/netconsole.c
+++ b/net/netconsole.c
@@ -185,7 +185,7 @@ static int netconsole_init(void)
 
ret = console_register(cdev);
if (ret) {
-   printf(netconsole: registering failed with %s\n, 
strerror(-ret));
+   pr_err(netconsole: registering failed with %s\n, 
strerror(-ret));
kfree(priv);
return ret;
}
@@ -194,7 +194,7 @@ static int netconsole_init(void)
dev_add_param(cdev-class_dev, port, nc_port_set, NULL, 0);
dev_set_param(cdev-class_dev, port, );
 
-   printf(registered netconsole as %s%d\n, cdev-class_dev.name, 
cdev-class_dev.id);
+   pr_info(registered netconsole as %s%d\n, cdev-class_dev.name, 
cdev-class_dev.id);
 
return 0;
 }
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/9] console: switch to kfifo_dump_str

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/console.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/common/console.c b/common/console.c
index beb37bd..243d402 100644
--- a/common/console.c
+++ b/common/console.c
@@ -55,6 +55,11 @@ static struct kfifo __console_output_fifo;
 static struct kfifo *console_input_fifo = __console_input_fifo;
 static struct kfifo *console_output_fifo = __console_output_fifo;
 
+static void console_output_dump(unsigned char ch)
+{
+   console_putc(CONSOLE_STDOUT, ch);
+}
+
 static int console_std_set(struct device_d *dev, struct param_d *param,
const char *val)
 {
@@ -86,14 +91,12 @@ static int console_std_set(struct device_d *dev, struct 
param_d *param,
dev_param_set_generic(dev, param, active);
 
if (initialized  CONSOLE_INIT_FULL) {
-   char ch;
initialized = CONSOLE_INIT_FULL;
PUTS_LL(Switch to console [);
PUTS_LL(dev_name(dev));
PUTS_LL(]\n);
barebox_banner();
-   while (kfifo_getc(console_output_fifo, ch) == 0)
-   console_putc(CONSOLE_STDOUT, ch);
+   kfifo_dump_str(console_output_fifo, console_output_dump);
}
 
return 0;
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/9] intoduce dmesg to print the barebox printk to dmesg ring buffer

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
the size can be configured vai DMESG_KFIFO_OSIZE

1024 by default
4096 if DEBUG_INFO

the verbosity of the printk can now be change at runtime and default via
PRINTK_LEVEL

rename dev_printf to dev_printk and update to printk

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 commands/Kconfig|   19 +++
 common/console.c|  118 +++
 drivers/base/driver.c   |   18 --
 include/linux/barebox-wrapper.h |   11 
 include/printk.h|   68 +++---
 5 files changed, 197 insertions(+), 37 deletions(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index c1454c7..a6d3846 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -122,6 +122,25 @@ config CMD_TIME
  checking for ctrl-c, so the time command can be used with commands
  which are interruptible with ctrl-c.
 
+config CMD_DMESG
+   bool dmesg
+   depends on CONSOLE_FULL
+ help
+ print the barebox output ring buffer
+
+if CMD_DMESG
+config PRINTK_LEVEL
+   int printk level
+   range 0 7
+   default 7
+
+config DMESG_KFIFO_SIZE
+   prompt kfifo dmesg size
+   int
+   default 4086 if DEBUG_INFO
+   default 1024
+endif
+
 config CMD_LINUX_EXEC
bool linux exec
depends on LINUX
diff --git a/common/console.c b/common/console.c
index 243d402..8cd74d6 100644
--- a/common/console.c
+++ b/common/console.c
@@ -1,3 +1,4 @@
+
 /*
  * (C) Copyright 2000
  * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arse...@tin.it
@@ -349,3 +350,120 @@ int ctrlc (void)
 }
 EXPORT_SYMBOL(ctrlc);
 #endif /* ARCH_HAS_CTRC */
+
+#ifdef CONFIG_CMD_DMESG
+#include command.h
+#include complete.h
+#include init.h
+#include globalvar.h
+
+static char dmesg_output_buffer[CONFIG_DMESG_KFIFO_SIZE];
+static struct kfifo __dmesg_output_fifo;
+static struct kfifo *dmesg_output_fifo = __dmesg_output_fifo;
+static int printk_level = CONFIG_PRINTK_LEVEL;
+static char printk_level_str[2] = __stringify(CONFIG_PRINTK_LEVEL);
+
+static int printk_level_set(struct device_d *dev, struct param_d *p, const 
char *val)
+{
+   int level = simple_strtoul(val, NULL, 10);
+
+   if (level  0 || level  7)
+   return -EINVAL;
+
+   printk_level = level;
+   printk_level_str[0] = level + '0';
+
+   return 0;
+}
+
+const char *printk_level_get(struct device_d *d, struct param_d *p)
+{
+   return printk_level_str;
+}
+
+static int printk_init(void)
+{
+   return globalvar_add(printk_level, printk_level_set, 
printk_level_get, 0);
+}
+coredevice_initcall(printk_init);
+
+static int printk_fifo_init(void)
+{
+   kfifo_init(dmesg_output_fifo, dmesg_output_buffer,
+   CONFIG_DMESG_KFIFO_SIZE);
+
+   return 0;
+}
+pure_initcall(printk_fifo_init);
+
+static int do_dmesg(int argc, char *argv[])
+{
+   kfifo_dump_str(dmesg_output_fifo, console_output_dump);
+
+   return 0;
+}
+
+static const __maybe_unused char cmd_dmesg_help[] =
+print the barebox output ring buffer\n;
+
+BAREBOX_CMD_START(dmesg)
+   .cmd= do_dmesg,
+   .usage  = dmesg,
+   BAREBOX_CMD_HELP(cmd_dmesg_help)
+   BAREBOX_CMD_COMPLETE(empty_complete)
+BAREBOX_CMD_END
+
+int vprintk (const char *fmt, va_list args)
+{
+   uint i;
+   char printbuffer[CFG_PBSIZE];
+   char *s = printbuffer;
+   int level;
+
+   /* For this to work, printbuffer must be larger than
+* anything we ever want to print.
+*/
+   i = vsprintf(printbuffer, fmt, args);
+
+   level = printk_get_level(printbuffer);
+   if (level) {
+   s += 2;
+   kfifo_putc(dmesg_output_fifo, '');
+   kfifo_putc(dmesg_output_fifo, level);
+   kfifo_putc(dmesg_output_fifo, '');
+   }
+
+   /* Print the string */
+   if (level  printk_level + '0') {
+   printf(%c  %c\n, level, printk_level + '0');
+   puts(s);
+   }
+
+   while (*s) {
+   if (*s == '\n')
+   kfifo_putc(dmesg_output_fifo, '\r');
+   kfifo_putc(dmesg_output_fifo, *s);
+   s++;
+   }
+
+   return i;
+}
+EXPORT_SYMBOL(vprintk);
+
+int printk (const char *fmt, ...)
+{
+   va_list args;
+   uint i;
+
+   va_start (args, fmt);
+
+   i = vprintk(fmt, args);
+   /* For this to work, printbuffer must be larger than
+* anything we ever want to print.
+*/
+   va_end (args);
+
+   return i;
+}
+EXPORT_SYMBOL(printk);
+#endif
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index fa30c68..17a11c8 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -364,23 +364,29 @@ const char *dev_id(const struct device_d *dev)
return buf;
 }
 
-int dev_printf(const struct device_d *dev, const char *format, ...)
+#define PREFIX 
+
+int dev_printk(const struct 

[PATCH 8/9] startup: switch to pr_xxx

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/startup.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index e49cc4c..ff00ca7 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -120,7 +120,7 @@ void __noreturn start_barebox(void)
ret = envfs_load(default_environment_path, /env, 0);
 
if (ret  IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT)) {
-   printf(no valid environment found on %s. 
+   pr_err(no valid environment found on %s. 
Using default environment\n,
default_environment_path);
envfs_load(/dev/defaultenv, /env, 0);
@@ -128,17 +128,17 @@ void __noreturn start_barebox(void)
}
 
if (IS_ENABLED(CONFIG_COMMAND_SUPPORT)) {
-   printf(running /env/bin/init...\n);
+   pr_info(running /env/bin/init...\n);
 
if (!stat(/env/bin/init, s)) {
run_command(source /env/bin/init, 0);
} else {
-   printf(not found\n);
+   pr_err(/env/bin/init not found\n);
}
}
 
if (!barebox_main) {
-   printf(No main function! aborting.\n);
+   pr_err(No main function! aborting.\n);
hang();
}
 
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 6/9] meminfo: switch to pr_xxx

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/meminfo.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/meminfo.c b/common/meminfo.c
index 5e3ff71..45733da 100644
--- a/common/meminfo.c
+++ b/common/meminfo.c
@@ -10,9 +10,9 @@ static int display_meminfo(void)
ulong mend   = mem_malloc_end();
ulong msize  = mend - mstart + 1;
 
-   debug(barebox code: 0x%p - 0x%p\n, _stext, _etext - 1);
-   debug(bss segment:  0x%p - 0x%p\n, __bss_start, __bss_stop - 1);
-   printf(malloc space: 0x%08lx - 0x%08lx (size %s)\n,
+   pr_debug(barebox code: 0x%p - 0x%p\n, _stext, _etext - 1);
+   pr_debug(bss segment:  0x%p - 0x%p\n, __bss_start, __bss_stop - 1);
+   pr_info(malloc space: 0x%08lx - 0x%08lx (size %s)\n,
mstart, mend, size_human_readable(msize));
return 0;
 }
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 0/9 v4] introduction of dmesg support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
HI,

v4: remove a debug info

v3: add more swtich

we currently have 2 fifo at comsole level one for input one for output
we fill the output fifo before any console is registered and then
empty it

Now we introduce a new mecanism as in the kernel dmesg

we will always fill the dmesg kfifo with drivers output

as in barebox we have 2 world

device/drivers and applicaiotn (commands)

the verbositty of the printk can be selected at runtime and
compilation

so for now on drivers will have to use pr_xxx and dev_xxx and
application will use printf

dmesg will print the kfifo at any time

we will extend this later with more control of what the drivers output
on the console or just in the fifo

This new feature is optionnal if dmes is disable we continue as before

The following changes since commit 94e71b843f6456abacc2fe76a5c375a461fabdf7:

  libubi: Use global mtd_all_ff function (2013-03-04 10:54:46 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/dmesg

for you to fetch changes up to b79c3fdbf9dcba5b38befc249663236890e3d295:

  barebox_banner: switch to pr_info (2013-03-04 19:33:49 +0800)


Jean-Christophe PLAGNIOL-VILLARD (9):
  kfifo: introduce kfifo_dump_str to dump the fifo
  console: switch to kfifo_dump_str
  intoduce dmesg to print the barebox printk to dmesg ring buffer
  startup: switch to pr_xxx
  at91: clock switch to pr_info
  meminfo: switch to pr_xxx
  net/console: switch to pr_xxx
  startup: switch to pr_xxx
  barebox_banner: switch to pr_info

 arch/arm/mach-at91/clock.c  |2 +-
 commands/Kconfig|   19 +++
 common/console.c|  125 
++---
 common/meminfo.c|6 +++---
 common/startup.c|   12 ++--
 common/version.c|4 ++--
 drivers/base/driver.c   |   18 --
 include/kfifo.h |2 ++
 include/linux/barebox-wrapper.h |   11 ---
 include/printk.h|   68 

 lib/kfifo.c |   21 +
 net/netconsole.c|4 ++--
 12 files changed, 238 insertions(+), 54 deletions(-)

Best Regards,
J.

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 4/9] startup: switch to pr_xxx

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/startup.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index 52a8996..e49cc4c 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -105,14 +105,14 @@ void __noreturn start_barebox(void)
 
for (initcall = __barebox_initcalls_start;
initcall  __barebox_initcalls_end; initcall++) {
-   debug(initcall- %pS\n, *initcall);
+   pr_debug(initcall- %pS\n, *initcall);
result = (*initcall)();
if (result)
pr_err(initcall %pS failed: %s\n, *initcall,
strerror(-result));
}
 
-   debug(initcalls done\n);
+   pr_debug(initcalls done\n);
 
if (IS_ENABLED(CONFIG_ENV_HANDLING)) {
int ret;
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/9] kfifo: introduce kfifo_dump_str to dump the fifo

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to implement a dmesg mecanism in barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 include/kfifo.h |2 ++
 lib/kfifo.c |   21 +
 2 files changed, 23 insertions(+)

diff --git a/include/kfifo.h b/include/kfifo.h
index 25880f4..9dbbe0d 100644
--- a/include/kfifo.h
+++ b/include/kfifo.h
@@ -74,5 +74,7 @@ static inline unsigned int kfifo_len(struct kfifo *fifo)
 void kfifo_putc(struct kfifo *fifo, unsigned char c);
 unsigned int kfifo_getc(struct kfifo *fifo, unsigned char *c);
 
+void kfifo_dump_str(struct kfifo *fifo, void (*dump)(unsigned char c));
+
 #endif
 
diff --git a/lib/kfifo.c b/lib/kfifo.c
index afd3894..7892aed 100644
--- a/lib/kfifo.c
+++ b/lib/kfifo.c
@@ -154,3 +154,24 @@ unsigned int kfifo_getc(struct kfifo *fifo, unsigned char 
*c)
return 0;
 }
 
+void kfifo_dump_str(struct kfifo *fifo, void (*dump)(unsigned char c))
+{
+   int i;
+   unsigned char *c;
+   unsigned int l;
+   unsigned int len;
+
+   len = fifo-in - fifo-out;
+
+   /* first get the data from fifo-out until the end of the buffer */
+   l = min(len, fifo-size - (fifo-out  (fifo-size - 1)));
+   c = fifo-buffer + (fifo-out  (fifo-size - 1));
+   for (i = 0; i  l; i++)
+   dump(c[i]);
+
+   /* then get the rest (if any) from the beginning of the buffer */
+   c = fifo-buffer;
+   l = len - l;
+   for (i = 0; i  l; i++)
+   dump(c[i]);
+}
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 5/9] at91: clock switch to pr_info

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 arch/arm/mach-at91/clock.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index 2dde632..296f5d5 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -756,7 +756,7 @@ static int at91_clock_display(void)
if (pll_overclock)
pr_info(Clocks: PLLA overclocked, %ld MHz\n, plla.rate_hz / 
100);
 
-   printf(Clocks: CPU %u MHz, master %u MHz, main %u.%03u MHz\n,
+   pr_info(Clocks: CPU %u MHz, master %u MHz, main %u.%03u MHz\n,
cpu_freq / 100, (unsigned) mck.rate_hz / 100,
(unsigned) main_clk.rate_hz / 100,
((unsigned) main_clk.rate_hz % 100) / 1000);
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 6/9] meminfo: switch to pr_xxx

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/meminfo.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/meminfo.c b/common/meminfo.c
index 5e3ff71..45733da 100644
--- a/common/meminfo.c
+++ b/common/meminfo.c
@@ -10,9 +10,9 @@ static int display_meminfo(void)
ulong mend   = mem_malloc_end();
ulong msize  = mend - mstart + 1;
 
-   debug(barebox code: 0x%p - 0x%p\n, _stext, _etext - 1);
-   debug(bss segment:  0x%p - 0x%p\n, __bss_start, __bss_stop - 1);
-   printf(malloc space: 0x%08lx - 0x%08lx (size %s)\n,
+   pr_debug(barebox code: 0x%p - 0x%p\n, _stext, _etext - 1);
+   pr_debug(bss segment:  0x%p - 0x%p\n, __bss_start, __bss_stop - 1);
+   pr_info(malloc space: 0x%08lx - 0x%08lx (size %s)\n,
mstart, mend, size_human_readable(msize));
return 0;
 }
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 7/9] net/console: switch to pr_xxx

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 net/netconsole.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netconsole.c b/net/netconsole.c
index 7d0f3f4..8db8356 100644
--- a/net/netconsole.c
+++ b/net/netconsole.c
@@ -185,7 +185,7 @@ static int netconsole_init(void)
 
ret = console_register(cdev);
if (ret) {
-   printf(netconsole: registering failed with %s\n, 
strerror(-ret));
+   pr_err(netconsole: registering failed with %s\n, 
strerror(-ret));
kfree(priv);
return ret;
}
@@ -194,7 +194,7 @@ static int netconsole_init(void)
dev_add_param(cdev-class_dev, port, nc_port_set, NULL, 0);
dev_set_param(cdev-class_dev, port, );
 
-   printf(registered netconsole as %s%d\n, cdev-class_dev.name, 
cdev-class_dev.id);
+   pr_info(registered netconsole as %s%d\n, cdev-class_dev.name, 
cdev-class_dev.id);
 
return 0;
 }
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 8/9] startup: switch to pr_xxx

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/startup.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index e49cc4c..ff00ca7 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -120,7 +120,7 @@ void __noreturn start_barebox(void)
ret = envfs_load(default_environment_path, /env, 0);
 
if (ret  IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT)) {
-   printf(no valid environment found on %s. 
+   pr_err(no valid environment found on %s. 
Using default environment\n,
default_environment_path);
envfs_load(/dev/defaultenv, /env, 0);
@@ -128,17 +128,17 @@ void __noreturn start_barebox(void)
}
 
if (IS_ENABLED(CONFIG_COMMAND_SUPPORT)) {
-   printf(running /env/bin/init...\n);
+   pr_info(running /env/bin/init...\n);
 
if (!stat(/env/bin/init, s)) {
run_command(source /env/bin/init, 0);
} else {
-   printf(not found\n);
+   pr_err(/env/bin/init not found\n);
}
}
 
if (!barebox_main) {
-   printf(No main function! aborting.\n);
+   pr_err(No main function! aborting.\n);
hang();
}
 
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/9] console: switch to kfifo_dump_str

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/console.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/common/console.c b/common/console.c
index beb37bd..243d402 100644
--- a/common/console.c
+++ b/common/console.c
@@ -55,6 +55,11 @@ static struct kfifo __console_output_fifo;
 static struct kfifo *console_input_fifo = __console_input_fifo;
 static struct kfifo *console_output_fifo = __console_output_fifo;
 
+static void console_output_dump(unsigned char ch)
+{
+   console_putc(CONSOLE_STDOUT, ch);
+}
+
 static int console_std_set(struct device_d *dev, struct param_d *param,
const char *val)
 {
@@ -86,14 +91,12 @@ static int console_std_set(struct device_d *dev, struct 
param_d *param,
dev_param_set_generic(dev, param, active);
 
if (initialized  CONSOLE_INIT_FULL) {
-   char ch;
initialized = CONSOLE_INIT_FULL;
PUTS_LL(Switch to console [);
PUTS_LL(dev_name(dev));
PUTS_LL(]\n);
barebox_banner();
-   while (kfifo_getc(console_output_fifo, ch) == 0)
-   console_putc(CONSOLE_STDOUT, ch);
+   kfifo_dump_str(console_output_fifo, console_output_dump);
}
 
return 0;
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 9/9] barebox_banner: switch to pr_info

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/version.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/version.c b/common/version.c
index 22e111a..d33f4d0 100644
--- a/common/version.c
+++ b/common/version.c
@@ -16,6 +16,6 @@ void barebox_banner (void)
if (!board)
board = CONFIG_BOARDINFO;
 
-   printf(\n\n%s\n\n, version_string);
-   printf(Board: %s\n, board);
+   pr_info(\n\n%s\n\n, version_string);
+   pr_info(Board: %s\n, board);
 }
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/9] intoduce dmesg to print the barebox printk to dmesg ring buffer

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
the size can be configured vai DMESG_KFIFO_OSIZE

1024 by default
4096 if DEBUG_INFO

the verbosity of the printk can now be change at runtime and default via
PRINTK_LEVEL

rename dev_printf to dev_printk and update to printk

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 commands/Kconfig|   19 +++
 common/console.c|  116 +++
 drivers/base/driver.c   |   18 --
 include/linux/barebox-wrapper.h |   11 
 include/printk.h|   68 ---
 5 files changed, 195 insertions(+), 37 deletions(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index c1454c7..a6d3846 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -122,6 +122,25 @@ config CMD_TIME
  checking for ctrl-c, so the time command can be used with commands
  which are interruptible with ctrl-c.
 
+config CMD_DMESG
+   bool dmesg
+   depends on CONSOLE_FULL
+ help
+ print the barebox output ring buffer
+
+if CMD_DMESG
+config PRINTK_LEVEL
+   int printk level
+   range 0 7
+   default 7
+
+config DMESG_KFIFO_SIZE
+   prompt kfifo dmesg size
+   int
+   default 4086 if DEBUG_INFO
+   default 1024
+endif
+
 config CMD_LINUX_EXEC
bool linux exec
depends on LINUX
diff --git a/common/console.c b/common/console.c
index 243d402..a7c8719 100644
--- a/common/console.c
+++ b/common/console.c
@@ -1,3 +1,4 @@
+
 /*
  * (C) Copyright 2000
  * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arse...@tin.it
@@ -349,3 +350,118 @@ int ctrlc (void)
 }
 EXPORT_SYMBOL(ctrlc);
 #endif /* ARCH_HAS_CTRC */
+
+#ifdef CONFIG_CMD_DMESG
+#include command.h
+#include complete.h
+#include init.h
+#include globalvar.h
+
+static char dmesg_output_buffer[CONFIG_DMESG_KFIFO_SIZE];
+static struct kfifo __dmesg_output_fifo;
+static struct kfifo *dmesg_output_fifo = __dmesg_output_fifo;
+static int printk_level = CONFIG_PRINTK_LEVEL;
+static char printk_level_str[2] = __stringify(CONFIG_PRINTK_LEVEL);
+
+static int printk_level_set(struct device_d *dev, struct param_d *p, const 
char *val)
+{
+   int level = simple_strtoul(val, NULL, 10);
+
+   if (level  0 || level  7)
+   return -EINVAL;
+
+   printk_level = level;
+   printk_level_str[0] = level + '0';
+
+   return 0;
+}
+
+const char *printk_level_get(struct device_d *d, struct param_d *p)
+{
+   return printk_level_str;
+}
+
+static int printk_init(void)
+{
+   return globalvar_add(printk_level, printk_level_set, 
printk_level_get, 0);
+}
+coredevice_initcall(printk_init);
+
+static int printk_fifo_init(void)
+{
+   kfifo_init(dmesg_output_fifo, dmesg_output_buffer,
+   CONFIG_DMESG_KFIFO_SIZE);
+
+   return 0;
+}
+pure_initcall(printk_fifo_init);
+
+static int do_dmesg(int argc, char *argv[])
+{
+   kfifo_dump_str(dmesg_output_fifo, console_output_dump);
+
+   return 0;
+}
+
+static const __maybe_unused char cmd_dmesg_help[] =
+print the barebox output ring buffer\n;
+
+BAREBOX_CMD_START(dmesg)
+   .cmd= do_dmesg,
+   .usage  = dmesg,
+   BAREBOX_CMD_HELP(cmd_dmesg_help)
+   BAREBOX_CMD_COMPLETE(empty_complete)
+BAREBOX_CMD_END
+
+int vprintk (const char *fmt, va_list args)
+{
+   uint i;
+   char printbuffer[CFG_PBSIZE];
+   char *s = printbuffer;
+   int level;
+
+   /* For this to work, printbuffer must be larger than
+* anything we ever want to print.
+*/
+   i = vsprintf(printbuffer, fmt, args);
+
+   level = printk_get_level(printbuffer);
+   if (level) {
+   s += 2;
+   kfifo_putc(dmesg_output_fifo, '');
+   kfifo_putc(dmesg_output_fifo, level);
+   kfifo_putc(dmesg_output_fifo, '');
+   }
+
+   /* Print the string */
+   if (level = printk_level + '0')
+   puts(s);
+
+   while (*s) {
+   if (*s == '\n')
+   kfifo_putc(dmesg_output_fifo, '\r');
+   kfifo_putc(dmesg_output_fifo, *s);
+   s++;
+   }
+
+   return i;
+}
+EXPORT_SYMBOL(vprintk);
+
+int printk (const char *fmt, ...)
+{
+   va_list args;
+   uint i;
+
+   va_start (args, fmt);
+
+   i = vprintk(fmt, args);
+   /* For this to work, printbuffer must be larger than
+* anything we ever want to print.
+*/
+   va_end (args);
+
+   return i;
+}
+EXPORT_SYMBOL(printk);
+#endif
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index fa30c68..17a11c8 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -364,23 +364,29 @@ const char *dev_id(const struct device_d *dev)
return buf;
 }
 
-int dev_printf(const struct device_d *dev, const char *format, ...)
+#define PREFIX 
+
+int dev_printk(const struct device_d *dev, int level, const char *format, ...)
 {
va_list args;
-  

Re: [PATCH 1/1] devfs: add symlink support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
On 09:11 Wed 06 Mar , Sascha Hauer wrote:
 On Wed, Mar 06, 2013 at 09:01:18AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
 wrote:
  On 08:43 Wed 06 Mar , Sascha Hauer wrote:
   On Sat, Feb 16, 2013 at 12:35:53PM +0100, Jean-Christophe 
   PLAGNIOL-VILLARD wrote:
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 fs/devfs.c   |   70 
++
 include/driver.h |1 +
 2 files changed, 71 insertions(+)
   
   What's your usecase with this patch? Telling me could increase my
   motivation applying it.
  I use it to handle boot device and tty today
  
  so the application part does not care about the real hardware they always 
  have
  the same device (file) to search
 
 This is in the same league as I wanted to do with persistent device
 names. We should think about this in a more general way.
 
   
   One thing I see with this patch that the next thing would be to add
   directory support to debugfs in which case we might be better off
   adding real device nodes and remove the devfs like we have it now
   completely.
  yeah I've the idea to rewrite the devfs completly and the ramfs too
  
  as the ramfs should be at vfs level so the devfs will nearly implement 
  nothing
 
 vfs level? You would have to implement one first, we do not have a vfs
 level at all ;)
yeah because today we duplicate too much code so with this we wil reduce the
size of barebox

Best Regards,
J.

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] dummy malloc: Add licence header

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
On 09:17 Wed 06 Mar , Sascha Hauer wrote:
 Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
 ---
  common/dummy_malloc.c | 23 +++
  1 file changed, 23 insertions(+)
 
 diff --git a/common/dummy_malloc.c b/common/dummy_malloc.c
 index ccee521..dd36a5b 100644
 --- a/common/dummy_malloc.c
 +++ b/common/dummy_malloc.c
 @@ -1,3 +1,26 @@
 +/*
 + * Copyright (C) 2013 Sascha Hauer s.ha...@pengutronix.de
you earn the copyright since you create the file ;)

tks anyway

I'm sending the application support

with a partitial libc and curses with menu/panel/form support

but still missing network

Best Regards,
J.
 + *
 + * 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.
 + *
 + *
 + * As a special exception, if other files instantiate templates or use macros
 + * or inline functions from this file, or you compile this file and link it
 + * with other works to produce a work based on this file, this file does not
 + * by itself cause the resulting work to be covered by the GNU General Public
 + * License. However the source code for this file must still be made 
 available
 + * in accordance with section (3) of the GNU General Public License.
 +
 + * This exception does not invalidate any other reasons why a work based on
 + * this file might be covered by the GNU General Public License.
 + */
  #include common.h
  #include malloc.h
  
 -- 
 1.8.2.rc2
 
 
 ___
 barebox mailing list
 barebox@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/barebox

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC PATCH 00/20] introduce application support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
HI,

this patch serie introduce the application support to barebox

This will allow to run application at run time by calling barebox
syscalls and as this will be a stable ABI the application will able
the run against any barebox that support it

As the application are not linked to barebox the GPLv2 licence does
not apply.

This patch serie provide a small libc (partialy implemented) which is
under GPLv2 + exception

As a special exception, if other files instantiate templates or use macros
or inline functions from this file, or you compile this file and link it
with other works to produce a work based on this file, this file does not
by itself cause the resulting work to be covered by the GNU General Public
License. However the source code for this file must still be made available
in accordance with section (3) of the GNU General Public License.

This exception does not invalidate any other reasons why a work based on
this file might be covered by the GNU General Public License.

This also provide the curses support proted against the libary with 
some examples

One of the idea will be to create a curses interface bios like for 
barebox

The following changes since commit 94e71b843f6456abacc2fe76a5c375a461fabdf7:

  libubi: Use global mtd_all_ff function (2013-03-04 10:54:46 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/application

for you to fetch changes up to aa6566a71ec01c48ce12325e19d1027d7d11316f:

  highbank: enable application support (2013-03-04 20:02:32 +0800)


Jean-Christophe PLAGNIOL-VILLARD (20):
  Makefile: x_flags prepare for apps support
  tlsf_malloc: drop duplicate include
  kbuild: add application (app) target
  Introduce application (app) support
  app: Introduce libc support
  app: add some utils
  app: Introduce example application
  filetype: add barebox arm application
  arm: add application support
  app: printf: use HelenOS verison with wide char support
  app: printf: add version from contiki
  app: add tinycurses support
  app: curses: add pdcurses
  app: add test curses
  app: pdcurses: add libmenu
  app: pdcurses: add libform
  app: curses: add menu example
  app: curses: add panel example
  app: curses: add form example
  highbank: enable application support

 Makefile   |   53 ++-
 apps/Kconfig   |   60 +++
 apps/Makefile  |   32 ++
 apps/example/Makefile  |   14 +
 apps/example/example.h |7 +
 apps/example/list.c|   98 +
 apps/example/ls.c  |  127 ++
 apps/example/main.c|  231 +++
 apps/example/setjmp.c  |   24 ++
 apps/form_curses/Makefile  |   11 +
 apps/form_curses/main.c|  113 ++
 apps/include/appinfo.h |   60 +++
 apps/include/assert.h  |   32 ++
 apps/include/common.h  |   28 ++
 apps/include/ctype.h   |  100 +
 apps/include/dirent.h  |   24 ++
 apps/include/errno.h   |   24 ++
 apps/include/fcntl.h   |   25 ++
 apps/include/getopt.h  |   76 
 apps/include/libc_config.h |  139 +++
 apps/include/limits.h  |   38 ++
 apps/include/malloc.h  |   30 ++
 apps/include/module.h  |3 +
 apps/include/sections.h|   29 ++
 apps/include/setjmp.h  |   25 ++
 apps/include/stddef.h  |1 +
 apps/include/stdint.h  |   23 ++
 apps/include/stdio.h   |   69 
 apps/include/stdlib.h  |   32 ++
 apps/include/string.h  |   53 +++
 apps/include/sys/ioctl.h   |   12 +
 apps/include/sys/stat.h|   14 +
 apps/include/sys/syscall.h |   14 +
 apps/include/sys/types.h   |   15 +
 apps/include/time.h|   27 ++
 apps/include/unistd.h  |   46 +++
 apps/include/utils/ansi.h  |   37 ++
 apps/include/utils/getchar.h   |   22 ++
 apps/include/utils/list.h  |  114 ++
 apps/include/utils/termcap.h   |   23 ++
 apps/include/wchar.h   |   33 ++
 apps/lib/Kconfig   |1 +
 apps/lib/Makefile   

[PATCH 02/20] tlsf_malloc: drop duplicate include

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
config.h is not need and already inclued by Makefile

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/tlsf_malloc.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/common/tlsf_malloc.c b/common/tlsf_malloc.c
index 5c5bb61..cd01b56 100644
--- a/common/tlsf_malloc.c
+++ b/common/tlsf_malloc.c
@@ -17,10 +17,8 @@
  *
  */
 
-#include config.h
 #include malloc.h
 #include string.h
-#include malloc.h
 
 #include stdio.h
 #include module.h
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 08/20] filetype: add barebox arm application

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/filetype.c  |   35 +++
 include/filetype.h |2 ++
 2 files changed, 37 insertions(+)

diff --git a/common/filetype.c b/common/filetype.c
index 8652f1d..16b217b 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -23,6 +23,7 @@
 #include fs.h
 #include malloc.h
 #include errno.h
+#include linux/license.h
 
 struct filetype_str {
const char *name;   /* human readable filetype */
@@ -49,6 +50,8 @@ static const struct filetype_str filetype_str[] = {
[filetype_png] = { PNG image, png },
[filetype_ext] = { ext filesystem, ext },
[filetype_gpt] = { GUID Partition Table, gpt },
+   [filetype_arm_application] = { arm barebox application, 
arm-barebox-app},
+   [filetype_arm_gpl_application] = { arm barebox GPL compatible 
application, arm-barebox-gpl-app},
 };
 
 const char *file_type_to_string(enum filetype f)
@@ -151,6 +154,35 @@ enum filetype is_fat_or_mbr(const unsigned char *sector, 
unsigned long *bootsec)
return filetype_mbr;
 }
 
+bool is_barebox_app_gpl_compatible(const uint8_t *buf8, size_t bufsize)
+{
+   int i;
+
+   if (bufsize  12)
+   return false;
+
+   bufsize -= 12;
+
+   for (i = 0; i  bufsize; i++, buf8++) {
+   if (!strncmp(license=, buf8, 8) 
+   license_is_gpl_compatible(buf8 + 8))
+   return true;
+   }
+
+   return false;
+}
+
+enum filetype is_barebox_arm_app(const uint8_t *buf8, size_t bufsize)
+{
+   if (strcmp(buf8 + 0x20, barebox_arm_app))
+   return filetype_unknown;
+   /* license=GPL */
+   if (is_barebox_app_gpl_compatible(buf8 + 0x80, bufsize))
+   return filetype_arm_gpl_application;
+
+   return filetype_arm_application;
+}
+
 enum filetype file_detect_type(const void *_buf, size_t bufsize)
 {
const u32 *buf = _buf;
@@ -201,6 +233,9 @@ enum filetype file_detect_type(const void *_buf, size_t 
bufsize)
if (buf[9] == 0x016f2818 || buf[9] == 0x18286f01)
return filetype_arm_zimage;
 
+   type = is_barebox_arm_app(buf8, bufsize);
+   if (type != filetype_unknown)
+   return type;
if (bufsize  512)
return filetype_unknown;
 
diff --git a/include/filetype.h b/include/filetype.h
index 78ca5d2..09cdc99 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -24,6 +24,8 @@ enum filetype {
filetype_png,
filetype_ext,
filetype_gpt,
+   filetype_arm_application,
+   filetype_arm_gpl_application,
filetype_max,
 };
 
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 01/20] Makefile: x_flags prepare for apps support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
only include barebox header for barebox flags

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 Makefile  |5 +++--
 arch/arm/Makefile |7 ---
 arch/mips/Makefile|8 
 arch/ppc/Makefile |4 ++--
 arch/sandbox/Makefile |4 ++--
 arch/x86/Makefile |4 ++--
 scripts/Makefile.lib  |   13 +
 7 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/Makefile b/Makefile
index b5819fc..4df6464 100644
--- a/Makefile
+++ b/Makefile
@@ -297,7 +297,7 @@ LINUXINCLUDE:= -Iinclude \
-include include/generated/autoconf.h \
-include $(srctree)/include/linux/kconfig.h
 
-CPPFLAGS:= -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin 
-ffreestanding
+CPPFLAGS:= -D__KERNEL__ -D__BAREBOX__ -fno-builtin -ffreestanding
 
 CFLAGS  := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common -Os -pipe
@@ -315,6 +315,7 @@ export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS 
PERL UTS_MACHINE
 export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
 
 export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
+export AFLAGS_LINUXINCLUDE
 export CFLAGS CFLAGS_KERNEL
 export AFLAGS AFLAGS_KERNEL
 
@@ -1212,7 +1213,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   
$(wildcard $(rm-files))
 
 
 a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
- $(NOSTDINC_FLAGS) $(CPPFLAGS) \
+ $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(AFLAGS_LINUXINCLUDE) $(CPPFLAGS) \
  $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
 
 quiet_cmd_as_o_S = AS  $@
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index b98d6b8..100a3c4 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -47,7 +47,8 @@ AFLAGS_THUMB2 :=$(CFLAGS_THUMB2) -Wa$(comma)-mthumb
 endif
 
 CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y) -msoft-float $(CFLAGS_THUMB2)
-AFLAGS   += -include asm/unified.h -msoft-float $(AFLAGS_THUMB2)
+AFLAGS_LINUXINCLUDE += -include asm/unified.h
+AFLAGS   += -msoft-float $(AFLAGS_THUMB2)
 
 # Machine directory name.  This list is sorted alphanumerically
 # by CONFIG_* macro name.
@@ -166,9 +167,9 @@ board-$(CONFIG_MACH_SABRESD):= 
freescale-mx6-sabresd
 machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
 ifeq ($(KBUILD_SRC),)
-CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
+LINUXINCLUDE += $(patsubst %,-I%include,$(machdirs))
 else
-CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
+LINUXINCLUDE += $(patsubst %,-I$(srctree)/%include,$(machdirs))
 endif
 
 TEXT_BASE = $(CONFIG_TEXT_BASE)
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 3c565a4..cd83f06 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -81,9 +81,9 @@ board-$(CONFIG_BOARD_RZX50)   := rzx50
 machdirs := $(patsubst %,arch/mips/mach-%/,$(machine-y))
 
 ifeq ($(KBUILD_SRC),)
-CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
+LINUXINCLUDE += $(patsubst %,-I%include,$(machdirs))
 else
-CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
+LINUXINCLUDE += $(patsubst %,-I$(srctree)/%include,$(machdirs))
 endif
 
 ifeq ($(incdir-y),)
@@ -98,9 +98,9 @@ BOARD :=
 endif
 
 ifeq ($(KBUILD_SRC),)
-CPPFLAGS += -I$(BOARD)/include
+LINUXINCLUDE += -I$(BOARD)/include
 else
-CPPFLAGS += -I$(srctree)/$(BOARD)/include
+LINUXINCLUDE += -I$(srctree)/$(BOARD)/include
 endif
 
 ifneq ($(machine-y),)
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index f0322a2..0002bc7 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -31,9 +31,9 @@ endif
 machdirs := $(patsubst %,arch/ppc/mach-%/,$(machine-y))
 
 ifeq ($(KBUILD_SRC),)
-CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
+LINUXINCLUDE += $(patsubst %,-I%include,$(machdirs))
 else
-CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
+LINUXINCLUDE += $(patsubst %,-I$(srctree)/%include,$(machdirs))
 endif
 
 archprepare: maketools
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 596c8f8..061f2a0 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -25,9 +25,9 @@ CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \
 machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y))
 
 ifeq ($(KBUILD_SRC),)
-CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
+LINUXINCLUDE += $(patsubst %,-I%include,$(machdirs))
 else
-CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
+LINUXINCLUDE += $(patsubst %,-I$(srctree)/%include,$(machdirs))
 endif
 
 SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 518b37f..1d933b8 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -17,9 +17,9 @@ endif
 machdirs := $(patsubst %,arch/x86/mach-%/,$(machine-y))
 
 ifeq ($(KBUILD_SRC),)
-CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
+LINUXINCLUDE += $(patsubst %,-I%include,$(machdirs))
 else
-CPPFLAGS += 

[PATCH 06/20] app: add some utils

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
 - getchar_timeout
 - term (try to detect terminal size, position, ansi helper)
 - list

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 apps/Makefile|1 +
 apps/include/utils/ansi.h|   37 ++
 apps/include/utils/getchar.h |   22 
 apps/include/utils/list.h|  114 ++
 apps/include/utils/termcap.h |   23 +
 apps/utils/Makefile  |2 +
 apps/utils/getchar.c |   43 
 apps/utils/termcap.c |   97 +++
 8 files changed, 339 insertions(+)
 create mode 100644 apps/include/utils/ansi.h
 create mode 100644 apps/include/utils/getchar.h
 create mode 100644 apps/include/utils/list.h
 create mode 100644 apps/include/utils/termcap.h
 create mode 100644 apps/utils/Makefile
 create mode 100644 apps/utils/getchar.c
 create mode 100644 apps/utils/termcap.c

diff --git a/apps/Makefile b/apps/Makefile
index c5c5c48..28efb0d 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -16,6 +16,7 @@ $(obj)/include/barebox/syscalls.h: 
$(srctree)/include/apps/syscalls.h
$(call cmd,shipped)
 
 obj-y += libc/
+obj-y += utils/
 
 barebox-app-header += $(obj)/include/types.h
 barebox-app-header += $(obj)/include/barebox/syscalls.h
diff --git a/apps/include/utils/ansi.h b/apps/include/utils/ansi.h
new file mode 100644
index 000..64f81a8
--- /dev/null
+++ b/apps/include/utils/ansi.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD plag...@jcrosoft.com
+ *
+ * Under GPLv2 only
+ *
+ * As a special exception, if other files instantiate templates or use macros
+ * or inline functions from this file, or you compile this file and link it
+ * with other works to produce a work based on this file, this file does not
+ * by itself cause the resulting work to be covered by the GNU General Public
+ * License. However the source code for this file must still be made available
+ * in accordance with section (3) of the GNU General Public License.
+
+ * This exception does not invalidate any other reasons why a work based on
+ * this file might be covered by the GNU General Public License.
+ */
+
+#ifndef __UTILS_ANSI_H__
+#define __UTILS_ANSI_H__
+
+#define ansi_escape_m(d)   printf(\e[%dm, d);
+#define ansi_save_cusror() printf(\e[s)
+#define ansi_restore_cusror()  printf(\e[u)
+#define ansi_set_cursor(row, col)  printf(\e[%d;%dH, row, col)
+#define ansi_reverse(on)   ansi_escape_m((on) ? 7 : 27)
+#define ansi_start_reverse()   ansi_escape_m(7)
+#define ansi_end_reverse() ansi_escape_m(27)
+#define ansi_cursor_enable(on) printf( \e[?25%c, ( on ) ? 'h' : 'l' 
);
+#define ansi_clear()   printf(\e[2J\e[;H);
+#define ansi_bold(on)  ansi_escape_m((on) ? 1 : 22)
+#define ansi_blink(on) ansi_escape_m((on) ? 5 : 25)
+#define ansi_start_bold()  ansi_escape_m(1)
+#define ansi_end_bold()ansi_escape_m(22)
+#define ansi_start_altcharset()ansi_escape_m(14)
+#define ansi_end_altcharset()  ansi_escape_m(10)
+#define ansi_set_color(fg,bg)  printf(\e[%d;%dm, fg, bg)
+
+#endif /* __UTILS_ANSI_H__ */
diff --git a/apps/include/utils/getchar.h b/apps/include/utils/getchar.h
new file mode 100644
index 000..074d6b2
--- /dev/null
+++ b/apps/include/utils/getchar.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD plag...@jcrosoft.com
+ *
+ * Under GPLv2 only
+ *
+ * As a special exception, if other files instantiate templates or use macros
+ * or inline functions from this file, or you compile this file and link it
+ * with other works to produce a work based on this file, this file does not
+ * by itself cause the resulting work to be covered by the GNU General Public
+ * License. However the source code for this file must still be made available
+ * in accordance with section (3) of the GNU General Public License.
+
+ * This exception does not invalidate any other reasons why a work based on
+ * this file might be covered by the GNU General Public License.
+ */
+
+#ifndef __UTILS_GETCHAR_H__
+#define __UTILS_GETCHAR_H__
+
+int getchar_timeout(int ms);
+
+#endif /* __UTILS_GETCHAR_H__ */
diff --git a/apps/include/utils/list.h b/apps/include/utils/list.h
new file mode 100644
index 000..8a18dae
--- /dev/null
+++ b/apps/include/utils/list.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD plag...@jcrosoft.com
+ *
+ * Under GPLv2 only
+ *
+ * As a special exception, if other files instantiate templates or use macros
+ * or inline functions from this file, or you compile this file and link it
+ * with other works to produce a work based on this file, this file does not
+ * by itself cause the resulting work to be covered by the GNU General Public
+ * License. However the source code for this file must 

[PATCH 03/20] kbuild: add application (app) target

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to link compiled object (app-y) to the built-in-app.o across 
the source
tree that will be finally link to the applications (app-final-y).

Now we compile the source %.c in app-%.o and provide -D__APP__
so we can known in the source when it's compile for barebox or pbl or app.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 Makefile   |5 +++-
 scripts/Makefile.build |   78 +---
 scripts/Makefile.lib   |   23 --
 3 files changed, 99 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 4df6464..110f7aa 100644
--- a/Makefile
+++ b/Makefile
@@ -493,6 +493,7 @@ barebox-alldirs := $(sort $(barebox-dirs) $(patsubst 
%/,%,$(filter %/, \
 $(core-n) $(core-) $(drivers-n) $(drivers-) \
 $(net-n)  $(net-)  $(libs-n)$(libs-
 
+app-common-y   := $(patsubst %/, %/built-in-app.o, $(common-y))
 pbl-common-y   := $(patsubst %/, %/built-in-pbl.o, $(common-y))
 common-y   := $(patsubst %/, %/built-in.o, $(common-y))
 
@@ -523,6 +524,8 @@ common-y:= $(patsubst %/, %/built-in.o, $(common-y))
 # System.map is generated to document addresses of all kernel symbols
 
 barebox-common := $(common-y)
+barebox-app-common := $(app-common-y)
+export barebox-app-common
 barebox-pbl-common := $(pbl-common-y)
 export barebox-pbl-common
 barebox-all:= $(barebox-common)
@@ -733,7 +736,7 @@ barebox.srec: barebox
 
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
-$(sort $(barebox-head) $(barebox-common) ) $(barebox-lds) 
$(barebox-pbl-common): $(barebox-dirs) ;
+$(sort $(barebox-head) $(barebox-common) ) $(barebox-lds) 
$(barebox-pbl-common) $(barebox-app-common): $(barebox-dirs) ;
 
 # Handle descending into subdirectories listed in $(barebox-dirs)
 # Preset locale variables to speed up the build process. Limit locale
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index a95bbe4..600d1f7 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -15,6 +15,8 @@ obj-m :=
 lib-y :=
 lib-m :=
 pbl-y :=
+app-y :=
+app-final-y :=
 always :=
 targets :=
 subdir-y :=
@@ -98,7 +100,7 @@ ifneq ($(strip $(lib-y) $(lib-m) $(lib-n) $(lib-)),)
 lib-target := $(obj)/lib.a
 endif
 
-ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target) $(pbl-y)),)
+ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target) $(pbl-y) 
$(app-y)),)
 builtin-target := $(obj)/built-in.o
 endif
 
@@ -108,11 +110,23 @@ pbl-target := $(obj)/built-in-pbl.o
 endif
 endif
 
+ifeq ($(CONFIG_APPLICATIONS), y)
+ifneq ($(strip $(app-y) $(builtin-target)),)
+app-target := $(obj)/built-in-app.o
+endif
+
+ifneq ($(strip $(app-final-y)),)
+app-final-target := $(addprefix $(obj)/,$(app-final-y))
+app-final-bin-target := $(addsuffix .app,$(app-final-bin-target))
+endif
+
+endif
+
 # We keep a list of all modules in $(MODVERDIR)
 
-__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(pbl-target) 
$(extra-y)) \
+__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(pbl-target) 
$(app-target) $(extra-y)) \
 $(if $(KBUILD_MODULES),$(obj-m)) \
-$(subdir-ym) $(always)
+$(subdir-ym) $(always) $(app-final-target) $(app-final-bin-target)
@:
 
 # Linus' kernel sanity checking tool
@@ -185,10 +199,12 @@ cmd_cc_symtypes_c= \
 
 quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
 quiet_cmd_pbl_cc_o_c = PBLCC   $@
+quiet_cmd_app_cc_o_c = APPCC   $@
 
 ifndef CONFIG_MODVERSIONS
 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $
 cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) $(PBL_CPPFLAGS) -c -o $@ $
+cmd_app_cc_o_c = $(CC) -D__APP__ $(APP_CPPFLAGS) $(app_c_flags) -c -o $@ $
 
 else
 # When module versioning is enabled the following steps are executed:
@@ -239,8 +255,23 @@ define rule_pbl_cc_o_c
mv -f $(dot-target).tmp $(dot-target).cmd
 endef
 
+define rule_app_cc_o_c
+   $(call echo-cmd,checksrc) $(cmd_checksrc) \
+   $(call echo-cmd,app_cc_o_c) $(cmd_app_cc_o_c);\
+   $(cmd_modversions)\
+   scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,app_cc__o_c)' \
+ $(dot-target).tmp;  \
+   rm -f $(depfile); \
+   mv -f $(dot-target).tmp $(dot-target).cmd
+
+endef
+
 # Built-in and composite module parts
 
+app-%.o: %.c FORCE
+   $(call cmd,force_checksrc)
+   $(call if_changed_rule,app_cc_o_c)
+
 pbl-%.o: %.c FORCE
$(call cmd,force_checksrc)
$(call if_changed_rule,pbl_cc_o_c)
@@ -284,13 +315,19 @@ cmd_as_o_S   = $(CC) $(a_flags) -c -o $@ $
 quiet_cmd_pbl_as_o_S = PBLAS   $@
 cmd_pbl_as_o_S   = $(CC) -D__PBL__ $(a_flags) $(PBL_CPPFLAGS) -c -o $@ $
 
+quiet_cmd_app_as_o_S = APPAS   $@
+cmd_app_as_o_S   = $(CC) -D__APP__ $(app_a_flags) 

[PATCH 07/20] app: Introduce example application

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 apps/Kconfig   |3 +
 apps/Makefile  |5 ++
 apps/example/Makefile  |   14 +++
 apps/example/example.h |7 ++
 apps/example/list.c|   98 
 apps/example/ls.c  |  127 ++
 apps/example/main.c|  231 
 apps/example/setjmp.c  |   24 +
 8 files changed, 509 insertions(+)
 create mode 100644 apps/example/Makefile
 create mode 100644 apps/example/example.h
 create mode 100644 apps/example/list.c
 create mode 100644 apps/example/ls.c
 create mode 100644 apps/example/main.c
 create mode 100644 apps/example/setjmp.c

diff --git a/apps/Kconfig b/apps/Kconfig
index 4805c50..324e14d 100644
--- a/apps/Kconfig
+++ b/apps/Kconfig
@@ -37,4 +37,7 @@ config APP_FILE_MAX
 
 endmenu
 
+config APP_EXAMPLE
+   bool example
+
 endif
diff --git a/apps/Makefile b/apps/Makefile
index 28efb0d..7f609e7 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -5,6 +5,8 @@ export APP_CPPFLAGS
 
 apps-$(CONFIG_APP_EXAMPLE) += example
 
+apps-$(CONFIG_APP_EXAMPLE) += example
+
 $(obj)/application: $(apps-lds) $(apps-y)
 
 APP_CPPFLAGS   += -fdata-sections -ffunction-sections
@@ -20,3 +22,6 @@ obj-y += utils/
 
 barebox-app-header += $(obj)/include/types.h
 barebox-app-header += $(obj)/include/barebox/syscalls.h
+
+$(apps-y): $(barebox-app-header) $(barebox-app-common)
+   $(Q)$(MAKE) $(build)=apps/$@ apps/$@/$@.app
diff --git a/apps/example/Makefile b/apps/example/Makefile
new file mode 100644
index 000..22f8d68
--- /dev/null
+++ b/apps/example/Makefile
@@ -0,0 +1,14 @@
+targets := example.map
+
+# Make sure files are removed during clean
+extra-y   += example.map
+
+app-y += main.o
+app-y += ls.o
+app-y += list.o
+app-y += setjmp.o
+app-final-y = example
+
+OBJCOPYFLAGS_example.app = -O binary
+LDFLAGS_apps   := -Map $(obj)/example.map
+LDFLAGS_apps   += -static --gc-sections
diff --git a/apps/example/example.h b/apps/example/example.h
new file mode 100644
index 000..34675b4
--- /dev/null
+++ b/apps/example/example.h
@@ -0,0 +1,7 @@
+
+#define LS_RECURSIVE   1
+#define LS_SHOWARG 2
+#define LS_COLUMN  4
+int ls(const char *path, ulong flags);
+void test_list(void);
+void test_setjmp(void);
diff --git a/apps/example/list.c b/apps/example/list.c
new file mode 100644
index 000..fd5662d
--- /dev/null
+++ b/apps/example/list.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD plag...@jcrosoft.com
+ *
+ * Under GPLv2 only
+*/
+
+#include stdio.h
+#include string.h
+#include appinfo.h
+#include utils/list.h
+
+#define ARRAY_SIZE(arr)(sizeof(arr) / sizeof((arr)[0]))
+
+static LIST_HEAD(test);
+
+struct data {
+   char *name;
+   struct list_entry list;
+};
+
+struct data data[] = {
+   [0] = { .name = data0, },
+   [1] = { .name = data1, },
+   [2] = { .name = data2, },
+   [3] = { .name = data3, },
+};
+
+static void dump_list(void)
+{
+   struct list_entry *pos;
+   struct data *d;
+   int i;
+
+   i = 0;
+   list_for_each(pos, test) {
+   printf(data[%d].list = %p\n, i, pos);
+   i++;
+   }
+
+   i = 0;
+   list_for_each_entry(d, test, list) {
+   printf(data[%d].name = %s\n, i, d-name);
+   printf(data[%d].list = %p\n, i, d-list);
+   i++;
+   }
+}
+
+static void empty_list(void)
+{
+   struct data *d, *tmp;
+   int i;
+
+   i = 0;
+   list_for_each_entry_safe(d, tmp, test, list) {
+   printf(data[%d].name = %s\n, i, d-name);
+   printf(data[%d].list = %p\n, i, d-list);
+   list_del(d-list);
+   i++;
+   }
+}
+
+void test_list(void)
+{
+   int i;
+
+   puts(-- list test --\n);
+
+   puts(fill list\n);
+
+   for (i = 0; i  ARRAY_SIZE(data); i++) {
+   printf(data[%d].name = %s\n, i, data[i].name);
+   printf(data[%d].list = %p\n, i, data[i].list);
+   list_add(data[i].list, test);
+   }
+
+   puts(dump list\n);
+   dump_list();
+   puts(remove entry 2\n);
+   list_del(data[2].list);
+   puts(dump list\n);
+   dump_list();
+   puts(empty list\n);
+   empty_list();
+   puts(dump list\n);
+   dump_list();
+   printf(list is %s\n, list_empty(test) ? empty : filled);
+
+   puts(fill list tail\n);
+   for (i = 0; i  ARRAY_SIZE(data); i++) {
+   printf(data[%d].name = %s\n, i, data[i].name);
+   printf(data[%d].list = %p\n, i, data[i].list);
+   list_add_tail(data[i].list, test);
+   }
+   puts(dump list\n);
+   dump_list();
+
+   puts(-- end --\n\n);
+}
diff --git a/apps/example/ls.c b/apps/example/ls.c
new file mode 100644
index 000..bad0ccb
--- /dev/null
+++ b/apps/example/ls.c
@@ -0,0 +1,127 @@
+/*
+ * 

[PATCH 09/20] arm: add application support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 arch/arm/Kconfig   |1 +
 arch/arm/Makefile  |6 +-
 arch/arm/apps/Kconfig  |   11 
 arch/arm/apps/Makefile |6 ++
 arch/arm/apps/apps.lds.S   |   64 ++
 arch/arm/apps/binfmt.c |  111 
 arch/arm/apps/head.S   |   59 +
 arch/arm/apps/include/arch/asm/macro.h |   46 +
 arch/arm/apps/include/arch/setjmp.h|   26 
 arch/arm/apps/raise.c  |   27 
 arch/arm/apps/setjmp.S |   60 +
 arch/arm/apps/start.c  |   35 ++
 12 files changed, 451 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/apps/Kconfig
 create mode 100644 arch/arm/apps/Makefile
 create mode 100644 arch/arm/apps/apps.lds.S
 create mode 100644 arch/arm/apps/binfmt.c
 create mode 100644 arch/arm/apps/head.S
 create mode 100644 arch/arm/apps/include/arch/asm/macro.h
 create mode 100644 arch/arm/apps/include/arch/setjmp.h
 create mode 100644 arch/arm/apps/raise.c
 create mode 100644 arch/arm/apps/setjmp.S
 create mode 100644 arch/arm/apps/start.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f25dcf7..f30859b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -2,6 +2,7 @@ config ARM
bool
select HAS_KALLSYMS
select HAS_MODULES
+   select HAS_APPLICATIONS
select HAVE_CONFIGURABLE_TEXT_BASE
select HAVE_PBL_IMAGE
select HAVE_IMAGE_COMPRESSION
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 100a3c4..731d92a 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -275,9 +275,13 @@ else
 MACH :=
 endif
 
+APP_LDFLAGS += -L $(shell dirname `$(CC) $(CPPFLAGS) -print-libgcc-file-name`) 
-lgcc
+
 common-y += $(BOARD) $(MACH)
 common-y += arch/arm/lib/ arch/arm/cpu/
+common-$(CONFIG_APPLICATIONS) += arch/arm/apps/
 
 lds-y  := arch/arm/lib/barebox.lds
+apps-lds-y := arch/arm/apps/apps.lds
 
-CLEAN_FILES += include/generated/mach-types.h arch/arm/lib/barebox.lds 
barebox-flash-image
+CLEAN_FILES += include/generated/mach-types.h arch/arm/lib/barebox.lds 
arch/arm/apps/apps.lds barebox-flash-image
diff --git a/arch/arm/apps/Kconfig b/arch/arm/apps/Kconfig
new file mode 100644
index 000..8fcb79d
--- /dev/null
+++ b/arch/arm/apps/Kconfig
@@ -0,0 +1,11 @@
+
+config APP_TEXT_BASE_OFFSET
+   hex
+   default 0x80
+   prompt application text base offset
+   help
+ APP_TEXT_BASE = TEXT_BASE - APP_TEXT_BASE_OFFSET
+ all the application will be link at this address
+ the syscall table region of 0x2000 will be add
+ APP_TEXT_BASE - 0x2000 and then the malloc region at
+ APP_TEXT_BASE - 0x2000 - APP_MALLOC_SIZE
diff --git a/arch/arm/apps/Makefile b/arch/arm/apps/Makefile
new file mode 100644
index 000..c7e9a80
--- /dev/null
+++ b/arch/arm/apps/Makefile
@@ -0,0 +1,6 @@
+obj-y += binfmt.o
+app-y += head.o
+app-y += start.o
+app-y += raise.o
+app-y += setjmp.o
+extry-y += apps.lds
diff --git a/arch/arm/apps/apps.lds.S b/arch/arm/apps/apps.lds.S
new file mode 100644
index 000..b6e4ab9
--- /dev/null
+++ b/arch/arm/apps/apps.lds.S
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD plag...@jcrosoft.com
+ *
+ * Under GPLv2 only
+ *
+ * As a special exception, if other files instantiate templates or use macros
+ * or inline functions from this file, or you compile this file and link it
+ * with other works to produce a work based on this file, this file does not
+ * by itself cause the resulting work to be covered by the GNU General Public
+ * License. However the source code for this file must still be made available
+ * in accordance with section (3) of the GNU General Public License.
+
+ * This exception does not invalidate any other reasons why a work based on
+ * this file might be covered by the GNU General Public License.
+ */
+
+#include sizes.h
+#include asm-generic/barebox.lds.h
+#include asm-generic/memory_layout.h
+
+#define HEAD_BASE (TEXT_BASE - CONFIG_APP_TEXT_BASE_OFFSET)
+
+OUTPUT_FORMAT(elf32-littlearm, elf32-littlearm, elf32-littlearm)
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+   . = HEAD_BASE;
+
+   . = ALIGN(4);
+   .text  :
+   {
+   _stext = .;
+   _text = .;
+   *(.text_head_entry*)
+   . = 0x80;
+   KEEP(*(.appinfo.start))
+   __appinfo_start = .;
+   KEEP(*(.appinfo))
+   __appinfo_end = .;
+   KEEP(*(.appinfo.end))
+   *(.text*)
+   }
+
+   /* Discard unwind if enable in barebox */
+   /DISCARD/ : { *(.ARM.ex*) }
+
+   . = ALIGN(4);
+   .rodata : { *(.rodata*) }
+
+   _etext = .; /* End of text and rodata section */
+
+   . = 

[PATCH 04/20] Introduce application (app) support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 Makefile|   47 -
 apps/Kconfig|   21 +++
 apps/Makefile   |   19 ++
 apps/include/appinfo.h  |   58 ++
 arch/arm/Kconfig|1 +
 commands/Kconfig|7 +
 commands/Makefile   |1 +
 commands/appinfo.c  |  119 +
 common/Kconfig  |3 +
 include/apps/syscall_init.h |   23 +++
 include/apps/syscalls.h |   76 
 include/apps/types.h|   24 +++
 include/linux/license.h |   14 ++
 lib/Makefile|1 +
 lib/apps/Makefile   |1 +
 lib/apps/syscalls.c |  413 +++
 16 files changed, 825 insertions(+), 3 deletions(-)
 create mode 100644 apps/Kconfig
 create mode 100644 apps/Makefile
 create mode 100644 apps/include/appinfo.h
 create mode 100644 commands/appinfo.c
 create mode 100644 include/apps/syscall_init.h
 create mode 100644 include/apps/syscalls.h
 create mode 100644 include/apps/types.h
 create mode 100644 include/linux/license.h
 create mode 100644 lib/apps/Makefile
 create mode 100644 lib/apps/syscalls.c

diff --git a/Makefile b/Makefile
index 110f7aa..706a1d4 100644
--- a/Makefile
+++ b/Makefile
@@ -297,6 +297,18 @@ LINUXINCLUDE:= -Iinclude \
-include include/generated/autoconf.h \
-include $(srctree)/include/linux/kconfig.h
 
+# Use APPINCLUDE when you must reference the include/ directory.
+# Needed to be compatible with the O= option
+APPINCLUDE:= -Iapps/include \
+   $(if $(KBUILD_SRC), -I$(srctree)/apps/include) \
+   $(if $(KBUILD_SRC), -I$(objtree)/include) \
+  -I$(srctree)/arch/$(ARCH)/include \
+  -I$(objtree)/arch/$(ARCH)/include \
+  -I$(srctree)/arch/$(ARCH)/apps/include \
+  -I$(objtree)/apps/include \
+   -include include/generated/autoconf.h \
+   -include $(srctree)/include/linux/kconfig.h
+
 CPPFLAGS:= -D__KERNEL__ -D__BAREBOX__ -fno-builtin -ffreestanding
 
 CFLAGS  := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
@@ -315,9 +327,10 @@ export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS 
PERL UTS_MACHINE
 export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
 
 export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
-export AFLAGS_LINUXINCLUDE
+export APPINCLUDE AFLAGS_LINUXINCLUDE
 export CFLAGS CFLAGS_KERNEL
 export AFLAGS AFLAGS_KERNEL
+export APP_LDFLAGS
 
 # Files to ignore in find ... statements
 
@@ -482,7 +495,18 @@ export KBUILD_BINARY ?= barebox.bin
 barebox-flash-image: $(KBUILD_IMAGE) FORCE
$(call if_changed,ln)
 
-all: barebox-flash-image
+ifdef CONFIG_APPLICATIONS
+apps-lds:= $(apps-lds-y)
+export apps-lds
+
+apps := apps
+application: barebox-flash-image
+   $(Q)$(MAKE) $(build)=$(apps) $(apps)/$@
+
+APPS-y += application
+endif
+
+all: barebox-flash-image $(APPS-y)
 
 common-$(CONFIG_PBL_IMAGE) += pbl/
 
@@ -493,7 +517,7 @@ barebox-alldirs := $(sort $(barebox-dirs) $(patsubst 
%/,%,$(filter %/, \
 $(core-n) $(core-) $(drivers-n) $(drivers-) \
 $(net-n)  $(net-)  $(libs-n)$(libs-
 
-app-common-y   := $(patsubst %/, %/built-in-app.o, $(common-y))
+app-common-y   := $(patsubst %/, %/built-in-app.o, $(common-y) apps/)
 pbl-common-y   := $(patsubst %/, %/built-in-pbl.o, $(common-y))
 common-y   := $(patsubst %/, %/built-in.o, $(common-y))
 
@@ -840,6 +864,23 @@ ifneq ($(KBUILD_SRC),)
/bin/false; \
fi;
$(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
+   $(Q)if [ ! -d apps/include ]; then mkdir -p apps/include; fi;
+   $(Q)if [ ! -d apps/include/barebox ]; then mkdir -p 
apps/include/barebox; fi;
+   $(Q)if [ ! -h apps/include/linux ]; then  \
+   ln -fsn $(srctree)/include/linux apps/include/linux; \
+   fi;
+   $(Q)if [ ! -h apps/include/asm-generic ]; then  \
+   ln -fsn $(srctree)/include/asm-generic apps/include/asm-generic;
 \
+   fi;
+   $(Q)if [ ! -h apps/include/generated ]; then  \
+   ln -fsn $(objtree)/include/generated apps/include/generated; \
+   fi;
+   $(Q)if [ ! -e apps/include/barebox/fcntl.h ]; then  \
+   ln -fsn $(srctree)/include/fcntl.h apps/include/barebox/fcntl.h;
 \
+   fi;
+   $(Q)if [ ! -e apps/include/barebox/types.h ]; then  \
+   ln -fsn $(srctree)/include/apps/types.h 
apps/include/barebox/types.h; \
+   fi;
$(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/barebox.h ]; then  \
ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \
fi
diff --git a/apps/Kconfig b/apps/Kconfig
new file mode 100644
index 000..92899b5
--- /dev/null
+++ b/apps/Kconfig
@@ -0,0 +1,21 @@

[PATCH 11/20] app: printf: add version from contiki

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
the strformat is taken from contiki OS which is under 3-clause BSD license
no wide char support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 apps/libc/Kconfig |9 +
 apps/libc/Makefile|1 +
 apps/libc/contiki/Makefile|1 +
 apps/libc/contiki/strformat.c |  621 +
 apps/libc/contiki/strformat.h |   25 ++
 apps/libc/contiki/vsprintf.c  |  116 
 6 files changed, 773 insertions(+)
 create mode 100644 apps/libc/contiki/Makefile
 create mode 100644 apps/libc/contiki/strformat.c
 create mode 100644 apps/libc/contiki/strformat.h
 create mode 100644 apps/libc/contiki/vsprintf.c

diff --git a/apps/libc/Kconfig b/apps/libc/Kconfig
index 25b35ee..8d4fbd6 100644
--- a/apps/libc/Kconfig
+++ b/apps/libc/Kconfig
@@ -24,6 +24,10 @@ config APP_PRINTF_STACK_SIZE
 
 choice
prompt printf implementation
+   default APPS_PRINTF_HELENOS
+
+config APPS_PRINTF_CONTIKI
+   bool contiki
 
 config APPS_PRINTF_HELENOS
bool helen os
@@ -32,4 +36,9 @@ config APPS_PRINTF_HELENOS
 
 endchoice
 
+config APP_PRINTF_STACK_SIZE
+   hex printf stack size
+   default 0x1000
+   depends on APPS_PRINTF_CONTIKI
+
 endmenu
diff --git a/apps/libc/Makefile b/apps/libc/Makefile
index c84f00e..832833c 100644
--- a/apps/libc/Makefile
+++ b/apps/libc/Makefile
@@ -15,6 +15,7 @@ app-y += unistd.o
 app-$(CONFIG_APPS_MALLOC_DUMMY) += dummy_malloc.o
 app-$(CONFIG_APPS_MALLOC_TLSF) += tlsf_malloc.o tlsf.o
 app-y += string.o
+obj-$(CONFIG_APPS_PRINTF_CONTIKI) += contiki/
 obj-$(CONFIG_APPS_PRINTF_HELENOS) += helenos/
 obj-y += sys/
 app-y += time.o
diff --git a/apps/libc/contiki/Makefile b/apps/libc/contiki/Makefile
new file mode 100644
index 000..e77ee5c
--- /dev/null
+++ b/apps/libc/contiki/Makefile
@@ -0,0 +1 @@
+app-y += vsprintf.o strformat.o
diff --git a/apps/libc/contiki/strformat.c b/apps/libc/contiki/strformat.c
new file mode 100644
index 000..82f0535
--- /dev/null
+++ b/apps/libc/contiki/strformat.c
@@ -0,0 +1,621 @@
+/*
+ * from contiki 3-clause BSD license
+ */
+#include strformat.h
+
+#ifdef __APP__
+#define HAVE_DOUBLE
+#endif
+
+#define HAVE_LONGLONG
+#ifndef LARGEST_SIGNED
+#ifdef HAVE_LONGLONG
+#define LARGEST_SIGNED long long int
+#else
+#define LARGEST_SIGNED long int
+#endif
+#endif
+
+#ifndef LARGEST_UNSIGNED
+#ifdef HAVE_LONGLONG
+#define LARGEST_UNSIGNED unsigned long long int
+#else
+#define LARGEST_UNSIGNED unsigned long int
+#endif
+#endif
+
+#ifndef POINTER_INT
+#define POINTER_INT unsigned long
+#endif
+
+typedef unsigned int FormatFlags;
+
+#define MAKE_MASK(shift,size) (((1  size) - 1)  (shift))
+
+#define JUSTIFY_SHIFT  0
+#define JUSTIFY_SIZE   1
+#define JUSTIFY_RIGHT  0x
+#define JUSTIFY_LEFT   0x0001
+#define JUSTIFY_MASK   MAKE_MASK(JUSTIFY_SHIFT,JUSTIFY_SIZE)
+
+
+/* How a positive number is prefixed */
+#define POSITIVE_SHIFT (JUSTIFY_SHIFT + JUSTIFY_SIZE)
+#define POSITIVE_NONE  (0x  POSITIVE_SHIFT)
+#define POSITIVE_SPACE (0x0001  POSITIVE_SHIFT)
+#define POSITIVE_PLUS  (0x0003  POSITIVE_SHIFT)
+#define POSITIVE_MASK  MAKE_MASK(POSITIVE_SHIFT, POSITIVE_SIZE)
+
+#define POSITIVE_SIZE  2
+
+#define ALTERNATE_FORM_SHIFT (POSITIVE_SHIFT + POSITIVE_SIZE)
+#define ALTERNATE_FORM_SIZE 1
+#define ALTERNATE_FORM  (0x0001  ALTERNATE_FORM_SHIFT)
+
+
+#define PAD_SHIFT  (ALTERNATE_FORM_SHIFT + ALTERNATE_FORM_SIZE)
+#define PAD_SIZE   1
+#define PAD_SPACE  (0x  PAD_SHIFT)
+#define PAD_ZERO   (0x0001  PAD_SHIFT)
+
+#define SIZE_SHIFT (PAD_SHIFT + PAD_SIZE)
+#define SIZE_SIZE  3
+#define SIZE_CHAR  (0x0001  SIZE_SHIFT)
+#define SIZE_SHORT (0x0002  SIZE_SHIFT)
+#define SIZE_INT   (0x  SIZE_SHIFT)
+#define SIZE_LONG  (0x0003  SIZE_SHIFT)
+#define SIZE_LONGLONG  (0x0004  SIZE_SHIFT)
+#define SIZE_MASK  MAKE_MASK(SIZE_SHIFT,SIZE_SIZE)
+
+#define CONV_SHIFT (SIZE_SHIFT + SIZE_SIZE)
+#define CONV_SIZE  3
+#define CONV_INTEGER   (0x0001  CONV_SHIFT)
+#define CONV_FLOAT (0x0002  CONV_SHIFT)
+#define CONV_POINTER   (0x0003  CONV_SHIFT)
+#define CONV_STRING(0x0004  CONV_SHIFT)
+#define CONV_CHAR  (0x0005  CONV_SHIFT)
+#define CONV_PERCENT   (0x0006  CONV_SHIFT)
+#define CONV_WRITTEN   (0x0007  CONV_SHIFT)
+#define CONV_MASK  MAKE_MASK(CONV_SHIFT, CONV_SIZE)
+
+#define RADIX_SHIFT(CONV_SHIFT + CONV_SIZE)
+#define RADIX_SIZE 2
+#define RADIX_DECIMAL  (0x0001  RADIX_SHIFT)
+#define RADIX_OCTAL(0x0002  RADIX_SHIFT)
+#define RADIX_HEX  (0x0003  RADIX_SHIFT)
+#define RADIX_MASK MAKE_MASK(RADIX_SHIFT,RADIX_SIZE)
+
+#define SIGNED_SHIFT   (RADIX_SHIFT + RADIX_SIZE)
+#define SIGNED_SIZE1
+#define SIGNED_NO  (0x  SIGNED_SHIFT)
+#define SIGNED_YES (0x0001  SIGNED_SHIFT)
+#define SIGNED_MASKMAKE_MASK(SIGNED_SHIFT,SIGNED_SIZE)
+
+#define CAPS_SHIFT (SIGNED_SHIFT + SIGNED_SIZE)
+#define CAPS_SIZE  1
+#define CAPS_NO(0x  CAPS_SHIFT)
+#define CAPS_YES   

[PATCH 14/20] app: add test curses

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 apps/Kconfig  |4 ++
 apps/Makefile |3 +-
 apps/test_curses/Makefile |   11 +++
 apps/test_curses/main.c   |  172 +
 4 files changed, 188 insertions(+), 2 deletions(-)
 create mode 100644 apps/test_curses/Makefile
 create mode 100644 apps/test_curses/main.c

diff --git a/apps/Kconfig b/apps/Kconfig
index a025955..7c0b79e 100644
--- a/apps/Kconfig
+++ b/apps/Kconfig
@@ -41,4 +41,8 @@ endmenu
 config APP_EXAMPLE
bool example
 
+config APP_TEST_CURSES
+   bool test curses
+   select APP_LIB_CURSES
+
 endif
diff --git a/apps/Makefile b/apps/Makefile
index cce547e..3a222d3 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -6,8 +6,7 @@ APP_CPPFLAGS += $(APP_CPPFLAGS-y)
 export APP_CPPFLAGS
 
 apps-$(CONFIG_APP_EXAMPLE) += example
-
-apps-$(CONFIG_APP_EXAMPLE) += example
+apps-$(CONFIG_APP_TEST_CURSES) += test_curses
 
 $(obj)/application: $(apps-lds) $(apps-y)
 
diff --git a/apps/test_curses/Makefile b/apps/test_curses/Makefile
new file mode 100644
index 000..94207a1
--- /dev/null
+++ b/apps/test_curses/Makefile
@@ -0,0 +1,11 @@
+targets := test_curses.map
+
+# Make sure files are removed during clean
+extra-y   += test_curses.map
+
+app-y += main.o
+app-final-y = test_curses
+
+OBJCOPYFLAGS_test_curses.app = -O binary
+LDFLAGS_apps   := -Map $(obj)/test_curses.map
+LDFLAGS_apps   += -static --gc-sections
diff --git a/apps/test_curses/main.c b/apps/test_curses/main.c
new file mode 100644
index 000..54f08f2
--- /dev/null
+++ b/apps/test_curses/main.c
@@ -0,0 +1,172 @@
+/*
+ * This file is part of the bayou project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include string.h
+#include stdlib.h
+#include curses.h
+
+#define SCREEN_Y LINES
+#define SCREEN_X COLS
+
+#define ARRAY_SIZE(arr)(sizeof(arr) / sizeof((arr)[0]))
+
+static int menu_width = 0;
+static int m_entries = 4;
+static unsigned int selected = 0;
+static WINDOW *menuwin, *status;
+char *i_name[] = {test0, test1, test2, test3 };
+
+char *get_name(int i)
+{
+   return i_name[i];
+}
+
+void create_menu(void)
+{
+   int i;
+
+   for (i = 0; i  ARRAY_SIZE(i_name); i++) {
+   char *name = get_name(i);
+
+   if (strlen(name)  menu_width)
+   menu_width = strlen(name);
+   }
+
+   menu_width += 4;
+
+   if (menu_width  30)
+   menu_width = 30;
+
+   menuwin = newwin(m_entries + 3, menu_width,
+(SCREEN_Y - (m_entries + 3)) / 2,
+(SCREEN_X - menu_width) / 2);
+
+}
+
+void draw_menu(void)
+{
+   int i;
+
+   wattrset(menuwin, COLOR_PAIR(3));
+   wbkgd(menuwin, COLOR_PAIR(3));
+   wclear(menuwin);
+   wborder(menuwin, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
+   ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER);
+
+   wattrset(menuwin, COLOR_PAIR(4) | A_BOLD);
+   mvwprintw(menuwin, 0, (menu_width - 17) / 2,  Chooser );
+
+   wattrset(menuwin, COLOR_PAIR(3));
+
+   for (i = 0; i  m_entries; i++) {
+   char *name = get_name(i);
+   int col = (menu_width - (2 + strlen(name))) / 2;
+
+   if (i == selected)
+   wattrset(menuwin, COLOR_PAIR(5) | A_BOLD);
+   else
+   wattrset(menuwin, COLOR_PAIR(3));
+
+   mvwprintw(menuwin, 2 + i, col, name);
+   }
+
+
+   wclear(status);
+
+   mvwprintw(status, 0, (SCREEN_X - 10) / 2, test);
+
+   wrefresh(menuwin);
+   wrefresh(status);
+}
+
+#if 0
+#define debug(fmt, arg...) debug(fmt, ##arg)
+#else
+#define debug(fmt, arg...)
+#endif
+
+void loop(void)
+{
+   int key;
+
+   while (1) {
+   key = getch();
+
+   debug(loop key = 0x%x\n, key);
+
+   if (key == ERR)
+   continue;
+
+   debug(loop key = 0x%x\n, key);
+
+   if (key == 'q') {
+   clear();
+   refresh();
+   endwin();
+   exit(0);
+   }
+   else if (key == KEY_DOWN)
+   selected = (selected + 1) % 

[PATCH 17/20] app: curses: add menu example

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 apps/Kconfig  |4 ++
 apps/Makefile |1 +
 apps/menu_curses/Makefile |   11 
 apps/menu_curses/main.c   |  127 +
 4 files changed, 143 insertions(+)
 create mode 100644 apps/menu_curses/Makefile
 create mode 100644 apps/menu_curses/main.c

diff --git a/apps/Kconfig b/apps/Kconfig
index 7c0b79e..e47f0c2 100644
--- a/apps/Kconfig
+++ b/apps/Kconfig
@@ -45,4 +45,8 @@ config APP_TEST_CURSES
bool test curses
select APP_LIB_CURSES
 
+config APP_TEST_CURSES_MENU
+   bool test curses menu
+   depends on APP_LIB_MENU
+
 endif
diff --git a/apps/Makefile b/apps/Makefile
index 3a222d3..47938ec 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -7,6 +7,7 @@ export APP_CPPFLAGS
 
 apps-$(CONFIG_APP_EXAMPLE) += example
 apps-$(CONFIG_APP_TEST_CURSES) += test_curses
+apps-$(CONFIG_APP_TEST_CURSES_MENU) += menu_curses
 
 $(obj)/application: $(apps-lds) $(apps-y)
 
diff --git a/apps/menu_curses/Makefile b/apps/menu_curses/Makefile
new file mode 100644
index 000..32c1a04
--- /dev/null
+++ b/apps/menu_curses/Makefile
@@ -0,0 +1,11 @@
+targets := menu_curses.map
+
+# Make sure files are removed during clean
+extra-y   += menu_curses.map
+
+app-y += main.o
+app-final-y = menu_curses
+
+OBJCOPYFLAGS_menu_curses.app = -O binary
+LDFLAGS_apps   := -Map $(obj)/menu_curses.map
+LDFLAGS_apps   += -static --gc-sections
diff --git a/apps/menu_curses/main.c b/apps/menu_curses/main.c
new file mode 100644
index 000..5b62caa
--- /dev/null
+++ b/apps/menu_curses/main.c
@@ -0,0 +1,127 @@
+#include string.h
+#include malloc.h
+#include curses.h
+#include menu.h
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+#define CTRLD  4
+
+char *choices[] = {
+   Choice 1,
+   Choice 2,
+   Choice 3,
+   Choice 4,
+   Choice 5,
+   Choice 6,
+   Choice 7,
+   Choice 8,
+   Choice 9,
+   Choice 10,
+   Exit,
+   (char *)NULL,
+   };
+void print_in_middle(WINDOW *win, int starty, int startx, int width, char 
*string, chtype color);
+
+int main(int argc, char **argv)
+{  ITEM **my_items;
+   int c;
+   MENU *my_menu;
+   WINDOW *my_menu_win;
+   int n_choices, i;
+
+   /* Initialize curses */
+   initscr();
+   start_color();
+   cbreak();
+   noecho();
+   keypad(stdscr, TRUE);
+   init_pair(1, COLOR_RED, COLOR_BLACK);
+   init_pair(2, COLOR_CYAN, COLOR_BLACK);
+
+   /* Create items */
+   n_choices = ARRAY_SIZE(choices);
+   my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *));
+   for(i = 0; i  n_choices; ++i)
+   my_items[i] = new_item(choices[i], choices[i]);
+
+   /* Crate menu */
+   my_menu = new_menu((ITEM **)my_items);
+
+   /* Create the window to be associated with the menu */
+   my_menu_win = newwin(10, 40, 4, 4);
+   keypad(my_menu_win, TRUE);
+
+   /* Set main window and sub window */
+   set_menu_win(my_menu, my_menu_win);
+   set_menu_sub(my_menu, derwin(my_menu_win, 6, 38, 3, 1));
+   set_menu_format(my_menu, 5, 1);
+
+   /* Set menu mark to the string  *  */
+   set_menu_mark(my_menu,  * );
+
+   /* Print a border around the main window and print a title */
+   box(my_menu_win, 0, 0);
+   print_in_middle(my_menu_win, 1, 0, 40, My Menu, COLOR_PAIR(1));
+   mvwaddch(my_menu_win, 2, 0, ACS_LTEE);
+   mvwhline(my_menu_win, 2, 1, ACS_HLINE, 38);
+   mvwaddch(my_menu_win, 2, 39, ACS_RTEE);
+
+   /* Post the menu */
+   post_menu(my_menu);
+   wrefresh(my_menu_win);
+
+   attron(COLOR_PAIR(2));
+   mvprintw(LINES - 2, 0, Use PageUp and PageDown to scoll down or up a 
page of items);
+   mvprintw(LINES - 1, 0, Arrow Keys to navigate (F1 to Exit));
+   attroff(COLOR_PAIR(2));
+   refresh();
+
+   while((c = wgetch(my_menu_win)) != KEY_F(1)) {
+   switch(c) {
+   case KEY_DOWN:
+   menu_driver(my_menu, REQ_DOWN_ITEM);
+   break;
+   case KEY_UP:
+   menu_driver(my_menu, REQ_UP_ITEM);
+   break;
+   case KEY_NPAGE:
+   menu_driver(my_menu, REQ_SCR_DPAGE);
+   break;
+   case KEY_PPAGE:
+   menu_driver(my_menu, REQ_SCR_UPAGE);
+   break;
+   }
+   wrefresh(my_menu_win);
+   }
+
+   /* Unpost and free all the memory taken up */
+   unpost_menu(my_menu);
+   free_menu(my_menu);
+   for(i = 0; i  n_choices; ++i)
+   free_item(my_items[i]);
+   

[PATCH 20/20] highbank: enable application support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 arch/arm/configs/highbank_defconfig |   21 +++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/arm/configs/highbank_defconfig 
b/arch/arm/configs/highbank_defconfig
index b034ed1..5776c68 100644
--- a/arch/arm/configs/highbank_defconfig
+++ b/arch/arm/configs/highbank_defconfig
@@ -4,15 +4,16 @@ CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
 CONFIG_PBL_IMAGE=y
 CONFIG_MMU=y
 CONFIG_MALLOC_SIZE=0xa0
+CONFIG_EXPERIMENTAL=y
 CONFIG_MALLOC_TLSF=y
 CONFIG_PROMPT=vexpress: 
 CONFIG_LONGHELP=y
-CONFIG_GLOB=y
 CONFIG_HUSH_FANCY_PROMPT=y
 CONFIG_CMDLINE_EDITING=y
 CONFIG_AUTO_COMPLETE=y
 CONFIG_MENU=y
-CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_PARTITION_DISK_EFI=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_DEFAULT_ENVIRONMENT_PATH=arch/arm/boards/highbank/env
 CONFIG_CMD_EDIT=y
 CONFIG_CMD_SLEEP=y
@@ -23,10 +24,16 @@ CONFIG_CMD_READLINE=y
 CONFIG_CMD_MENU=y
 CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_PASSWD=y
+CONFIG_CMD_LN=y
+CONFIG_CMD_READLINK=y
 CONFIG_CMD_TFTP=y
+CONFIG_CMD_FILETYPE=y
+CONFIG_CMD_APPINFO=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_LOADB=y
 CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_CRC_CMP=y
 CONFIG_CMD_BOOTM_SHOW_TYPE=y
 CONFIG_CMD_BOOTM_VERBOSE=y
 CONFIG_CMD_BOOTM_INITRD=y
@@ -60,3 +67,13 @@ CONFIG_GPIO_PL061=y
 CONFIG_FS_TFTP=y
 CONFIG_SHA1=y
 CONFIG_SHA256=y
+CONFIG_APPLICATIONS=y
+CONFIG_APP_LIB_PANEL=y
+CONFIG_APP_LIB_MENU=y
+CONFIG_APP_LIB_FORM=y
+CONFIG_APP_TEXT_BASE_OFFSET=0x100
+CONFIG_APP_EXAMPLE=y
+CONFIG_APP_TEST_CURSES=y
+CONFIG_APP_TEST_CURSES_PANEL=y
+CONFIG_APP_TEST_CURSES_MENU=y
+CONFIG_APP_TEST_CURSES_FORM=y
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 19/20] app: curses: add form example

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 apps/Kconfig  |4 ++
 apps/Makefile |1 +
 apps/form_curses/Makefile |   11 +
 apps/form_curses/main.c   |  113 +
 4 files changed, 129 insertions(+)
 create mode 100644 apps/form_curses/Makefile
 create mode 100644 apps/form_curses/main.c

diff --git a/apps/Kconfig b/apps/Kconfig
index 532b6fb..208978b 100644
--- a/apps/Kconfig
+++ b/apps/Kconfig
@@ -53,4 +53,8 @@ config APP_TEST_CURSES_MENU
bool test curses menu
depends on APP_LIB_MENU
 
+config APP_TEST_CURSES_FORM
+   bool test curses form
+   depends on APP_LIB_FORM
+
 endif
diff --git a/apps/Makefile b/apps/Makefile
index a26541a..f7696f0 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -9,6 +9,7 @@ apps-$(CONFIG_APP_EXAMPLE) += example
 apps-$(CONFIG_APP_TEST_CURSES) += test_curses
 apps-$(CONFIG_APP_TEST_CURSES_MENU) += menu_curses
 apps-$(CONFIG_APP_TEST_CURSES_PANEL) += panel_curses
+apps-$(CONFIG_APP_TEST_CURSES_FORM) += form_curses
 
 $(obj)/application: $(apps-lds) $(apps-y)
 
diff --git a/apps/form_curses/Makefile b/apps/form_curses/Makefile
new file mode 100644
index 000..9166c9d
--- /dev/null
+++ b/apps/form_curses/Makefile
@@ -0,0 +1,11 @@
+targets := form_curses.map
+
+# Make sure files are removed during clean
+extra-y   += form_curses.map
+
+app-y += main.o
+app-final-y = form_curses
+
+OBJCOPYFLAGS_form_curses.app = -O binary
+LDFLAGS_apps   := -Map $(obj)/form_curses.map
+LDFLAGS_apps   += -static --gc-sections
diff --git a/apps/form_curses/main.c b/apps/form_curses/main.c
new file mode 100644
index 000..d737a20
--- /dev/null
+++ b/apps/form_curses/main.c
@@ -0,0 +1,113 @@
+#include form.h
+#include string.h
+
+void print_in_middle(WINDOW *win, int starty, int startx, int width, char 
*string, chtype color);
+
+int main(int argc, char **argv)
+{
+   FIELD *field[3];
+   FORM  *my_form;
+   WINDOW *my_form_win;
+   int ch, rows, cols;
+   
+   /* Initialize curses */
+   initscr();
+   start_color();
+   cbreak();
+   noecho();
+   keypad(stdscr, TRUE);
+
+   /* Initialize few color pairs */
+   init_pair(1, COLOR_RED, COLOR_BLACK);
+
+   /* Initialize the fields */
+   field[0] = new_field(1, 10, 6, 1, 0, 0);
+   field[1] = new_field(1, 10, 8, 1, 0, 0);
+   field[2] = NULL;
+
+   /* Set field options */
+   set_field_back(field[0], A_UNDERLINE);
+   field_opts_off(field[0], O_AUTOSKIP); /* Don't go to next field when 
this */
+ /* Field is filled up 
*/
+   set_field_back(field[1], A_UNDERLINE); 
+   field_opts_off(field[1], O_AUTOSKIP);
+   
+   /* Create the form and post it */
+   my_form = new_form(field);
+   
+   /* Calculate the area required for the form */
+   scale_form(my_form, rows, cols);
+
+   /* Create the window to be associated with the form */
+my_form_win = newwin(rows + 4, cols + 4, 4, 4);
+keypad(my_form_win, TRUE);
+
+   /* Set main window and sub window */
+set_form_win(my_form, my_form_win);
+set_form_sub(my_form, derwin(my_form_win, rows, cols, 2, 2));
+
+   /* Print a border around the main window and print a title */
+box(my_form_win, 0, 0);
+   print_in_middle(my_form_win, 1, 0, cols + 4, My Form, COLOR_PAIR(1));
+   
+   post_form(my_form);
+   wrefresh(my_form_win);
+
+   mvprintw(LINES - 2, 0, Use UP, DOWN arrow keys to switch between 
fields);
+   refresh();
+
+   /* Loop through to get user requests */
+   while((ch = wgetch(my_form_win)) != KEY_F(1))
+   {   switch(ch)
+   {   case KEY_DOWN:
+   /* Go to next field */
+   form_driver(my_form, REQ_NEXT_FIELD);
+   /* Go to the end of the present buffer */
+   /* Leaves nicely at the last character */
+   form_driver(my_form, REQ_END_LINE);
+   break;
+   case KEY_UP:
+   /* Go to previous field */
+   form_driver(my_form, REQ_PREV_FIELD);
+   form_driver(my_form, REQ_END_LINE);
+   break;
+   default:
+   /* If this is a normal character, it gets */
+   /* Printed*/
+   form_driver(my_form, ch);
+   break;
+   }
+   }
+
+   /* Un post form and free the memory */
+   unpost_form(my_form);
+   free_form(my_form);
+   free_field(field[0]);
+   free_field(field[1]); 
+
+   endwin();
+   return 0;

[PATCH 18/20] app: curses: add panel example

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 apps/Kconfig   |4 ++
 apps/Makefile  |1 +
 apps/panel_curses/Makefile |   11 +
 apps/panel_curses/main.c   |  118 
 4 files changed, 134 insertions(+)
 create mode 100644 apps/panel_curses/Makefile
 create mode 100644 apps/panel_curses/main.c

diff --git a/apps/Kconfig b/apps/Kconfig
index e47f0c2..532b6fb 100644
--- a/apps/Kconfig
+++ b/apps/Kconfig
@@ -45,6 +45,10 @@ config APP_TEST_CURSES
bool test curses
select APP_LIB_CURSES
 
+config APP_TEST_CURSES_PANEL
+   bool test curses panel
+   depends on APP_LIB_PANEL
+
 config APP_TEST_CURSES_MENU
bool test curses menu
depends on APP_LIB_MENU
diff --git a/apps/Makefile b/apps/Makefile
index 47938ec..a26541a 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -8,6 +8,7 @@ export APP_CPPFLAGS
 apps-$(CONFIG_APP_EXAMPLE) += example
 apps-$(CONFIG_APP_TEST_CURSES) += test_curses
 apps-$(CONFIG_APP_TEST_CURSES_MENU) += menu_curses
+apps-$(CONFIG_APP_TEST_CURSES_PANEL) += panel_curses
 
 $(obj)/application: $(apps-lds) $(apps-y)
 
diff --git a/apps/panel_curses/Makefile b/apps/panel_curses/Makefile
new file mode 100644
index 000..b52c808
--- /dev/null
+++ b/apps/panel_curses/Makefile
@@ -0,0 +1,11 @@
+targets := panel_curses.map
+
+# Make sure files are removed during clean
+extra-y   += panel_curses.map
+
+app-y += main.o
+app-final-y = panel_curses
+
+OBJCOPYFLAGS_panel_curses.app = -O binary
+LDFLAGS_apps   := -Map $(obj)/panel_curses.map
+LDFLAGS_apps   += -static --gc-sections
diff --git a/apps/panel_curses/main.c b/apps/panel_curses/main.c
new file mode 100644
index 000..4be732f
--- /dev/null
+++ b/apps/panel_curses/main.c
@@ -0,0 +1,118 @@
+#include panel.h
+#include string.h
+
+#define NLINES 10
+#define NCOLS 40
+
+void init_wins(WINDOW **wins, int n);
+void win_show(WINDOW *win, char *label, int label_color);
+void print_in_middle(WINDOW *win, int starty, int startx, int width, char 
*string, chtype color);
+
+int main(int argc, char **argv)
+{  WINDOW *my_wins[3];
+   PANEL  *my_panels[3];
+   PANEL  *top;
+   int ch;
+
+   /* Initialize curses */
+   initscr();
+   start_color();
+   cbreak();
+   noecho();
+   keypad(stdscr, TRUE);
+
+   /* Initialize all the colors */
+   init_pair(1, COLOR_RED, COLOR_BLACK);
+   init_pair(2, COLOR_GREEN, COLOR_BLACK);
+   init_pair(3, COLOR_BLUE, COLOR_BLACK);
+   init_pair(4, COLOR_CYAN, COLOR_BLACK);
+
+   init_wins(my_wins, 3);
+   
+   /* Attach a panel to each window */ /* Order is bottom up */
+   my_panels[0] = new_panel(my_wins[0]);   /* Push 0, order: stdscr-0 */
+   my_panels[1] = new_panel(my_wins[1]);   /* Push 1, order: stdscr-0-1 */
+   my_panels[2] = new_panel(my_wins[2]);   /* Push 2, order: stdscr-0-1-2 
*/
+
+   /* Set up the user pointers to the next panel */
+   set_panel_userptr(my_panels[0], my_panels[1]);
+   set_panel_userptr(my_panels[1], my_panels[2]);
+   set_panel_userptr(my_panels[2], my_panels[0]);
+
+   /* Update the stacking order. 2nd panel will be on top */
+   update_panels();
+
+   /* Show it on the screen */
+   attron(COLOR_PAIR(4));
+   mvprintw(LINES - 2, 0, Use tab to browse through the windows (F1 to 
Exit));
+   attroff(COLOR_PAIR(4));
+   doupdate();
+
+   top = my_panels[2];
+   while((ch = getch()) != KEY_F(1))
+   {   switch(ch)
+   {   case 9:
+   top = (PANEL *)panel_userptr(top);
+   top_panel(top);
+   break;
+   }
+   update_panels();
+   doupdate();
+   }
+   endwin();
+   return 0;
+}
+
+/* Put all the windows */
+void init_wins(WINDOW **wins, int n)
+{  int x, y, i;
+   char label[80];
+
+   y = 2;
+   x = 10;
+   for(i = 0; i  n; ++i)
+   {   wins[i] = newwin(NLINES, NCOLS, y, x);
+   sprintf(label, Window Number %d, i + 1);
+   win_show(wins[i], label, i + 1);
+   y += 3;
+   x += 7;
+   }
+}
+
+/* Show the window with a border and a label */
+void win_show(WINDOW *win, char *label, int label_color)
+{  int startx, starty, height, width;
+
+   getbegyx(win, starty, startx);
+   getmaxyx(win, height, width);
+
+   box(win, 0, 0);
+   mvwaddch(win, 2, 0, ACS_LTEE); 
+   mvwhline(win, 2, 1, ACS_HLINE, width - 2); 
+   mvwaddch(win, 2, width - 1, ACS_RTEE); 
+   
+   print_in_middle(win, 1, 0, width, label, COLOR_PAIR(label_color));
+}
+
+void print_in_middle(WINDOW *win, int starty, int startx, int width, char 
*string, chtype color)
+{  int length, x, y;
+   float temp;
+
+   if(win == NULL)
+   win = stdscr;
+   getyx(win, y, 

Re: [PATCH 09/20] arm: add application support

2013-03-06 Thread Alexander Shiyan
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  arch/arm/Kconfig   |1 +
  arch/arm/Makefile  |6 +-
  arch/arm/apps/Kconfig  |   11 
  arch/arm/apps/Makefile |6 ++
  arch/arm/apps/apps.lds.S   |   64 ++
  arch/arm/apps/binfmt.c |  111 
 
  arch/arm/apps/head.S   |   59 +
  arch/arm/apps/include/arch/asm/macro.h |   46 +
  arch/arm/apps/include/arch/setjmp.h|   26 
  arch/arm/apps/raise.c  |   27 
  arch/arm/apps/setjmp.S |   60 +
  arch/arm/apps/start.c  |   35 ++
  12 files changed, 451 insertions(+), 1 deletion(-)
  create mode 100644 arch/arm/apps/Kconfig
  create mode 100644 arch/arm/apps/Makefile
  create mode 100644 arch/arm/apps/apps.lds.S
  create mode 100644 arch/arm/apps/binfmt.c
  create mode 100644 arch/arm/apps/head.S
  create mode 100644 arch/arm/apps/include/arch/asm/macro.h
  create mode 100644 arch/arm/apps/include/arch/setjmp.h
  create mode 100644 arch/arm/apps/raise.c
  create mode 100644 arch/arm/apps/setjmp.S
  create mode 100644 arch/arm/apps/start.c
...

Is this feature really needed? If we Include it, is dramatically increases size 
of BB.
We have a scripting, maybe just inclusion a small C interpreter is enough?
Such as picoc (http://code.google.com/p/picoc/), for example.

---
___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 09/20] arm: add application support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
On 13:59 Wed 06 Mar , Alexander Shiyan wrote:
  Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
  ---
   arch/arm/Kconfig   |1 +
   arch/arm/Makefile  |6 +-
   arch/arm/apps/Kconfig  |   11 
   arch/arm/apps/Makefile |6 ++
   arch/arm/apps/apps.lds.S   |   64 ++
   arch/arm/apps/binfmt.c |  111 
  
   arch/arm/apps/head.S   |   59 +
   arch/arm/apps/include/arch/asm/macro.h |   46 +
   arch/arm/apps/include/arch/setjmp.h|   26 
   arch/arm/apps/raise.c  |   27 
   arch/arm/apps/setjmp.S |   60 +
   arch/arm/apps/start.c  |   35 ++
   12 files changed, 451 insertions(+), 1 deletion(-)
   create mode 100644 arch/arm/apps/Kconfig
   create mode 100644 arch/arm/apps/Makefile
   create mode 100644 arch/arm/apps/apps.lds.S
   create mode 100644 arch/arm/apps/binfmt.c
   create mode 100644 arch/arm/apps/head.S
   create mode 100644 arch/arm/apps/include/arch/asm/macro.h
   create mode 100644 arch/arm/apps/include/arch/setjmp.h
   create mode 100644 arch/arm/apps/raise.c
   create mode 100644 arch/arm/apps/setjmp.S
   create mode 100644 arch/arm/apps/start.c
 ...
 
 Is this feature really needed? If we Include it, is dramatically increases 
 size of BB.
 We have a scripting, maybe just inclusion a small C interpreter is enough?
 Such as picoc (http://code.google.com/p/picoc/), for example.
increase?? no
 1 to 2 KiB

on barebox side you just have the syscall

it's nothing and this is optionnal

Best Regards,
J.
 
 ---

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 12/20] app: add tinycurses support

2013-03-06 Thread Sascha Hauer
On Wed, Mar 06, 2013 at 10:29:41AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 take from corboot and upated to use ansi
 
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com

Drop the curses stuff from the series. It will take time to get the
application stuff reviewed and merged, so concentrate on the basic stuff
and do not dump this unrelated stuff on the list.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 12/20] app: add tinycurses support

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
On 12:31 Wed 06 Mar , Sascha Hauer wrote:
 On Wed, Mar 06, 2013 at 10:29:41AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
 wrote:
  take from corboot and upated to use ansi
  
  Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 
 Drop the curses stuff from the series. It will take time to get the
 application stuff reviewed and merged, so concentrate on the basic stuff
 and do not dump this unrelated stuff on the list.
this will be presented this friday at CEWG so I choose to send it together and
it's a good example how to use the application implemetation

for the other version of this patch serie I'll not include it

Best Regards,
J.
 
 Sascha
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 0/5] Zynq support for barebox

2013-03-06 Thread Steffen Trumtrar
On Tue, Mar 05, 2013 at 11:09:29AM -0600, Josh Cartwright wrote:
 On Sun, Mar 03, 2013 at 03:58:10PM +0100, Steffen Trumtrar wrote:
  Hi!
  
  On Sat, Mar 02, 2013 at 07:20:12PM -0600, Josh Cartwright wrote:
   In San Francisco a couple weeks ago (ELC2013), Thomas Petazzoni
   informally mentioned barebox in passing, so I decided to toy with it a
   bit...
   
   This patchset adds basic support for the Zynq SoC to barebox.  So far,
   it's only been tested as a 'secondary' bootloader (after u-boot).  Also
   added is support for the zc702 development board.
   
  
  I have some patches laying around, that have support for booting first stage
  from a SD-Card on a ZedBoard. I didn't send them as of yet, because I'm not
  completely satisfied with them in one or two places. (The clocksource seems 
  to
  be inverse to what barebox expects, which would be a quick fix, and barebox 
  boots
  uuultra slow, if I do everything according to the TRM)
  At the moment, I do not have access to the board though. But I hope I can 
  get a
  hand on it in the next days.
 
 If you have a chance to send out what you have, I'd be curious to see
 it.  Fortunately I have several Zynq boards to play with.
 

Hi!

Have a look at
http://git.pengutronix.de/?p=str/barebox.git;a=summary

I stole your clk driver and added it to my patch stack :-)
Current state for ZedBoard:
- boot first stage from SD-Card
- barebox.bin needs to be processed with
./scripts/zynq_checksum barebox.bin BOOT.bin
to have the checksum in the BootROM header
- clocksource is arm_smp_tmd at seems accurate
- the BootROM needs about 4-5 seconds to copy barebox from
  SD to the OCM. I guess, I need to mess with the SD setup
  in the BootROM somehow
- just enough clkdev to use the timer
- all pinctrl, clk setup etc happens in the lowlevel init

Regards,
Steffen

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[RFC] Makefile: Create empty config.h if this header file is not needed by board

2013-03-06 Thread Alexander Shiyan
Patch creates empty config.h if this header is not needed by board.
This will allow to remove many empty config.h files from boards.

Signed-off-by: Alexander Shiyan shc_w...@mail.ru
---
 Makefile | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index b5819fc..e8d9984 100644
--- a/Makefile
+++ b/Makefile
@@ -898,13 +898,18 @@ include/asm:
$(Q)$(check-symlink)
$(Q)$(create-symlink)
 
+define symlink-config-h
+   if [ -f $(srctree)/$(BOARD)/config.h ]; then\
+   $(kecho) '  SYMLINK $@ - $(BOARD)/config.h';   \
+   ln -fsn $(srctree)/$(BOARD)/config.h $@;\
+   else\
+   $(kecho) '  CREATE  $@';\
+   echo -n  $@;   \
+   fi
+endef
+
 include/config.h: include/config/auto.conf
-   $(Q)$(kecho) '  SYMLINK $@ - $(BOARD)/config.h'
-ifneq ($(KBUILD_SRC),)
-   $(Q)ln -fsn $(srctree)/$(BOARD)/config.h $@
-else
-   $(Q)ln -fsn ../$(BOARD)/config.h $@
-endif
+   $(Q)$(symlink-config-h)
 
 # Generate some files
 # ---
-- 
1.7.12.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 7/9] net/console: switch to pr_xxx

2013-03-06 Thread Sascha Hauer
On Wed, Mar 06, 2013 at 09:39:50AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  net/netconsole.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/net/netconsole.c b/net/netconsole.c
 index 7d0f3f4..8db8356 100644
 --- a/net/netconsole.c
 +++ b/net/netconsole.c
 @@ -185,7 +185,7 @@ static int netconsole_init(void)
  
   ret = console_register(cdev);
   if (ret) {
 - printf(netconsole: registering failed with %s\n, 
 strerror(-ret));
 + pr_err(netconsole: registering failed with %s\n, 
 strerror(-ret));

When you rework the printfs please add a:

#define pr_fmt(fmt) netconsole:  fmt

to get a consistent layout of the pr_* messages.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/1] beagle: add missing mmc twl and control init

2013-03-06 Thread Jean-Christophe PLAGNIOL-VILLARD
take from xloader

with this the mmc work even when booting from nand

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 arch/arm/boards/beagle/board.c |   29 -
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/beagle/board.c b/arch/arm/boards/beagle/board.c
index bed4651..6e69e87 100644
--- a/arch/arm/boards/beagle/board.c
+++ b/arch/arm/boards/beagle/board.c
@@ -63,6 +63,7 @@
 #include linux/err.h
 #include usb/ehci.h
 #include mach/xload.h
+#include mfd/twl4030.h
 
 #ifdef CONFIG_DRIVER_SERIAL_NS16550
 
@@ -109,6 +110,32 @@ static struct gpmc_nand_platform_data nand_plat = {
.nand_cfg = omap3_nand_cfg,
 };
 
+/* T2 Register definitions */
+#define CONTROL_DEV_CONF0  0x48002274
+#define CONTROL_PBIAS_LITE 0x48002520
+
+static void beagle_add_mmc(void)
+{
+   unsigned int value = 0;
+   struct twl4030 *t = twl4030_get();
+
+   if (!t) {
+   pr_warn(twl4030 not ready to setup mmc\n);
+   } else {
+   twl4030_reg_write(t, TWL4030_USB_OTHER_FUNC_CTRL_CLR, 0x20);
+   twl4030_reg_write(t, TWL4030_USB_OTHER_IFC_CTRL_CLR, 0x2);
+   }
+
+   value = readl(CONTROL_PBIAS_LITE);
+   value |= (1  2) | (1  1) | (1  9);
+   writel(value, CONTROL_PBIAS_LITE);
+
+   value = readl(CONTROL_DEV_CONF0);
+   writel(value | (1  24), CONTROL_PBIAS_LITE);
+
+   omap3_add_mmc1(NULL);
+}
+
 static int beagle_mem_init(void)
 {
omap_add_ram0(SZ_128M);
@@ -132,7 +159,7 @@ static int beagle_devices_init(void)
 #endif
omap_add_gpmc_nand_device(nand_plat);
 
-   omap3_add_mmc1(NULL);
+   beagle_add_mmc();
 
armlinux_set_bootparams((void *)0x8100);
armlinux_set_architecture(MACH_TYPE_OMAP3_BEAGLE);
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 1/1] beagle: add missing mmc twl and control init

2013-03-06 Thread Alexander Aring
Hi,

On Thu, Mar 07, 2013 at 12:45:18AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 take from xloader
 
 with this the mmc work even when booting from nand
 
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  arch/arm/boards/beagle/board.c |   29 -
  1 file changed, 28 insertions(+), 1 deletion(-)
 
 diff --git a/arch/arm/boards/beagle/board.c b/arch/arm/boards/beagle/board.c
 index bed4651..6e69e87 100644
 --- a/arch/arm/boards/beagle/board.c
 +++ b/arch/arm/boards/beagle/board.c
 @@ -63,6 +63,7 @@
  #include linux/err.h
  #include usb/ehci.h
  #include mach/xload.h
 +#include mfd/twl4030.h
  
  #ifdef CONFIG_DRIVER_SERIAL_NS16550
  
 @@ -109,6 +110,32 @@ static struct gpmc_nand_platform_data nand_plat = {
   .nand_cfg = omap3_nand_cfg,
  };
  
 +/* T2 Register definitions */
 +#define CONTROL_DEV_CONF00x48002274
 +#define CONTROL_PBIAS_LITE   0x48002520
 +
 +static void beagle_add_mmc(void)
 +{
 + unsigned int value = 0;
 + struct twl4030 *t = twl4030_get();
 +
 + if (!t) {
 + pr_warn(twl4030 not ready to setup mmc\n);
 + } else {
 + twl4030_reg_write(t, TWL4030_USB_OTHER_FUNC_CTRL_CLR, 0x20);
 + twl4030_reg_write(t, TWL4030_USB_OTHER_IFC_CTRL_CLR, 0x2);
 + }
 +
 + value = readl(CONTROL_PBIAS_LITE);
 + value |= (1  2) | (1  1) | (1  9);
 + writel(value, CONTROL_PBIAS_LITE);
 +
 + value = readl(CONTROL_DEV_CONF0);
 + writel(value | (1  24), CONTROL_PBIAS_LITE);
 +
 + omap3_add_mmc1(NULL);
 +}
 +
  static int beagle_mem_init(void)
  {
   omap_add_ram0(SZ_128M);
 @@ -132,7 +159,7 @@ static int beagle_devices_init(void)
  #endif
   omap_add_gpmc_nand_device(nand_plat);
  
 - omap3_add_mmc1(NULL);
 + beagle_add_mmc();
  

I had a similar problem with twl6030 and pcm049 some time ago...

See commit:

659f150e90d8bfcf8aa4c51bd3ab552f42e288f0

Please make sure this will work when you insert a mmc card after
beagle_mem_init call.

In my case, I need to add the VMMC setup at probing time in omap_hsmmc.
The reason is that twl6030 doesn't setup VMMC if a mmc card is not insert.

Maybe twl4030 do the same.

Alex

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] fix another brown paper bag bug introduced with compile time loglevel

2013-03-06 Thread Sascha Hauer
__pr_printk is a define which uses a local variable 'ret'. This
means that whenever someone does a pr_*(ret: %d\n, ret);
ret will be 0.

Fix this by writing this without a local variable.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 include/printk.h | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/printk.h b/include/printk.h
index 3de8905..3cd7335 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -46,10 +46,7 @@ int dev_printf(const struct device_d *dev, const char 
*format, ...)
 
 #define __pr_printk(level, format, args...) \
({  \
-   int ret = 0;\
-   if (level = LOGLEVEL) \
-   ret = printk(format, ##args);   \
-   ret;\
+   (level) = LOGLEVEL ? printk((format), ##args) : 0; \
 })
 
 #ifndef pr_fmt
-- 
1.8.2.rc2


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 3/9] intoduce dmesg to print the barebox printk to dmesg ring buffer

2013-03-06 Thread Sascha Hauer
On Wed, Mar 06, 2013 at 09:39:46AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 the size can be configured vai DMESG_KFIFO_OSIZE
 
 1024 by default
 4096 if DEBUG_INFO
 
 the verbosity of the printk can now be change at runtime and default via
 PRINTK_LEVEL
 
 rename dev_printf to dev_printk and update to printk
 
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  commands/Kconfig|   19 +++
  common/console.c|  116 
 +++
  drivers/base/driver.c   |   18 --
  include/linux/barebox-wrapper.h |   11 
  include/printk.h|   68 ---
  5 files changed, 195 insertions(+), 37 deletions(-)
 
 diff --git a/commands/Kconfig b/commands/Kconfig
 index c1454c7..a6d3846 100644
 --- a/commands/Kconfig
 +++ b/commands/Kconfig
 @@ -122,6 +122,25 @@ config CMD_TIME
 checking for ctrl-c, so the time command can be used with commands
 which are interruptible with ctrl-c.
  
 +config CMD_DMESG
 + bool dmesg
 + depends on CONSOLE_FULL
 +   help
 +   print the barebox output ring buffer
 +
 +if CMD_DMESG
 +config PRINTK_LEVEL
 + int printk level
 + range 0 7
 + default 7
 +
 +config DMESG_KFIFO_SIZE
 + prompt kfifo dmesg size
 + int
 + default 4086 if DEBUG_INFO

Why 4086?

 + default 1024
 +endif
 +
  config CMD_LINUX_EXEC
   bool linux exec
   depends on LINUX
 diff --git a/common/console.c b/common/console.c
 index 243d402..a7c8719 100644
 --- a/common/console.c
 +++ b/common/console.c
 @@ -1,3 +1,4 @@
 +
  /*
   * (C) Copyright 2000
   * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arse...@tin.it
 @@ -349,3 +350,118 @@ int ctrlc (void)
  }
  EXPORT_SYMBOL(ctrlc);
  #endif /* ARCH_HAS_CTRC */
 +
 +#ifdef CONFIG_CMD_DMESG
 +#include command.h
 +#include complete.h
 +#include init.h
 +#include globalvar.h
 +
 +static char dmesg_output_buffer[CONFIG_DMESG_KFIFO_SIZE];
 +static struct kfifo __dmesg_output_fifo;
 +static struct kfifo *dmesg_output_fifo = __dmesg_output_fifo;
 +static int printk_level = CONFIG_PRINTK_LEVEL;
 +static char printk_level_str[2] = __stringify(CONFIG_PRINTK_LEVEL);
 +
 +static int printk_level_set(struct device_d *dev, struct param_d *p, const 
 char *val)
 +{
 + int level = simple_strtoul(val, NULL, 10);
 +
 + if (level  0 || level  7)
 + return -EINVAL;

simple_strtoul returns an unsigned type which is assigned to a signed
type and tested for  0 then. Use unsigned directly.

 +
 + printk_level = level;
 + printk_level_str[0] = level + '0';
 +
 + return 0;
 +}
 +
 +const char *printk_level_get(struct device_d *d, struct param_d *p)
 +{
 + return printk_level_str;
 +}
 +
 +static int printk_init(void)
 +{
 + return globalvar_add(printk_level, printk_level_set, 
 printk_level_get, 0);
 +}
 +coredevice_initcall(printk_init);
 +
 +static int printk_fifo_init(void)
 +{
 + kfifo_init(dmesg_output_fifo, dmesg_output_buffer,
 + CONFIG_DMESG_KFIFO_SIZE);
 +
 + return 0;
 +}
 +pure_initcall(printk_fifo_init);
 +
 +static int do_dmesg(int argc, char *argv[])
 +{
 + kfifo_dump_str(dmesg_output_fifo, console_output_dump);
 +
 + return 0;
 +}
 +
 +static const __maybe_unused char cmd_dmesg_help[] =
 +print the barebox output ring buffer\n;
 +
 +BAREBOX_CMD_START(dmesg)
 + .cmd= do_dmesg,
 + .usage  = dmesg,
 + BAREBOX_CMD_HELP(cmd_dmesg_help)
 + BAREBOX_CMD_COMPLETE(empty_complete)
 +BAREBOX_CMD_END
 +
 +int vprintk (const char *fmt, va_list args)
 +{
 + uint i;
 + char printbuffer[CFG_PBSIZE];
 + char *s = printbuffer;
 + int level;
 +
 + /* For this to work, printbuffer must be larger than
 +  * anything we ever want to print.
 +  */
 + i = vsprintf(printbuffer, fmt, args);
 +
 + level = printk_get_level(printbuffer);
 + if (level) {
 + s += 2;
 + kfifo_putc(dmesg_output_fifo, '');
 + kfifo_putc(dmesg_output_fifo, level);
 + kfifo_putc(dmesg_output_fifo, '');
 + }
 +
 + /* Print the string */
 + if (level = printk_level + '0')
 + puts(s);
 +
 + while (*s) {
 + if (*s == '\n')
 + kfifo_putc(dmesg_output_fifo, '\r');
 + kfifo_putc(dmesg_output_fifo, *s);
 + s++;
 + }

the '\r' should be added during outputting the on the serial line,
not while putting it into the buffer. Otherwise we have this in
the logs should we ever want to safe them to a file. catting these
files would then lead to double '\r'.

Also, wouldn't a kfifo_puts implementation make things easier and more
efficient here?

 +
 + return i;
 +}
 +EXPORT_SYMBOL(vprintk);
 +
 +int printk (const char *fmt, ...)
 +{
 + va_list args;
 + uint i;
 +
 + va_start (args, fmt);
 +
 + i = vprintk(fmt, args);
 + /* For this to work, 

Re: [RFC PATCH 00/20] introduce application support

2013-03-06 Thread Sascha Hauer
On Wed, Mar 06, 2013 at 10:26:43AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 HI,
 
   this patch serie introduce the application support to barebox
 
   This will allow to run application at run time by calling barebox
   syscalls and as this will be a stable ABI the application will able
   the run against any barebox that support it
 
   As the application are not linked to barebox the GPLv2 licence does
   not apply.
 
   This patch serie provide a small libc (partialy implemented) which is
   under GPLv2 + exception
 
 As a special exception, if other files instantiate templates or use macros
 or inline functions from this file, or you compile this file and link it
 with other works to produce a work based on this file, this file does not
 by itself cause the resulting work to be covered by the GNU General Public
 License. However the source code for this file must still be made available
 in accordance with section (3) of the GNU General Public License.
 
 This exception does not invalidate any other reasons why a work based on
 this file might be covered by the GNU General Public License.
 
   This also provide the curses support proted against the libary with 
 some examples

I'm fine with the app support in general, but I don't want to become the
maintainer of a proprietary software helper framework. So, if you want
curses and whatever stuff, create a separate repository for it. The
barebox repository ends at the syscall interface and an example
application for showing how to use it.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 02/20] tlsf_malloc: drop duplicate include

2013-03-06 Thread Sascha Hauer
On Wed, Mar 06, 2013 at 10:29:31AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 config.h is not need and already inclued by Makefile
 
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com

Applied, thanks

Sascha

 ---
  common/tlsf_malloc.c |2 --
  1 file changed, 2 deletions(-)
 
 diff --git a/common/tlsf_malloc.c b/common/tlsf_malloc.c
 index 5c5bb61..cd01b56 100644
 --- a/common/tlsf_malloc.c
 +++ b/common/tlsf_malloc.c
 @@ -17,10 +17,8 @@
   *
   */
  
 -#include config.h
  #include malloc.h
  #include string.h
 -#include malloc.h
  
  #include stdio.h
  #include module.h
 -- 
 1.7.10.4
 
 
 ___
 barebox mailing list
 barebox@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/barebox
 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 06/20] app: add some utils

2013-03-06 Thread Sascha Hauer
On Wed, Mar 06, 2013 at 10:34:44PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 On 22:21 Wed 06 Mar , Sascha Hauer wrote:
  On Wed, Mar 06, 2013 at 10:29:35AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
  wrote:
- getchar_timeout
- term (try to detect terminal size, position, ansi helper)
- list
   
   Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
   ---
   diff --git a/apps/include/utils/list.h b/apps/include/utils/list.h
   new file mode 100644
   index 000..8a18dae
   --- /dev/null
   +++ b/apps/include/utils/list.h
   @@ -0,0 +1,114 @@
   +/*
   + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD 
   plag...@jcrosoft.com
   + *
   + * Under GPLv2 only
   + *
   + * As a special exception, if other files instantiate templates or use 
   macros
   + * or inline functions from this file, or you compile this file and link 
   it
   + * with other works to produce a work based on this file, this file does 
   not
   + * by itself cause the resulting work to be covered by the GNU General 
   Public
   + * License. However the source code for this file must still be made 
   available
   + * in accordance with section (3) of the GNU General Public License.
   +
   + * This exception does not invalidate any other reasons why a work based 
   on
   + * this file might be covered by the GNU General Public License.
   + */
  
  This looks suspiciously like the Linux list implementation which I think you
  haven't written. Also who gives you the right to add this licence
  exception to code you do not own?
 I did wrote this for years about 10 I just update the code to looks like the
 linux one so I do own the code

LOL. I've written my own OS 25 years ago, I just updated the code to look
like Linux.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox