[U-Boot] [PATCH v2] Add command line arguments to Plan 9

2013-06-10 Thread Steven Stallion
This patch introduces support for command line arguments to Plan 9.
Plan 9 generally dedicates a small region of kernel memory (known
as CONFADDR) for runtime configuration.  A new environment variable
named confaddr was introduced to indicate this location when copying
arguments.

Signed-off-by: Steven Stallion sstall...@gmail.com
---
Changes for v2:
   - Corrected checkpatch misses
   - Refactored common code to copy command line arguments
   - Added documentation for odd Plan 9 behavior

 common/cmd_bootm.c |   36 +---
 doc/README.plan9   |   18 ++
 2 files changed, 47 insertions(+), 7 deletions(-)
 create mode 100644 doc/README.plan9

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 05130b6..960a68f 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -1346,6 +1346,19 @@ static void fixup_silent_linux(void)
 }
 #endif /* CONFIG_SILENT_CONSOLE */
 
+#if defined(CONFIG_BOOTM_NETBSD) || defined(CONFIG_BOOTM_PLAN9)
+static void copy_args(char *dest, int argc, char * const argv[], char delim)
+{
+   int i;
+
+   for (i = 0; i  argc; i++) {
+   if (i  0)
+   *dest++ = delim;
+   strcpy(dest, argv[i]);
+   dest += strlen(argv[i]);
+   }
+}
+#endif
 
 /***/
 /* OS booting routines */
@@ -1408,13 +1421,7 @@ static int do_bootm_netbsd(int flag, int argc, char * 
const argv[],
for (i = 2, len = 0; i  argc; i += 1)
len += strlen(argv[i]) + 1;
cmdline = malloc(len);
-
-   for (i = 2, len = 0; i  argc; i += 1) {
-   if (i  2)
-   cmdline[len++] = ' ';
-   strcpy(cmdline[len], argv[i]);
-   len += strlen(argv[i]);
-   }
+   copy_args(cmdline, argc-2, argv+2, ' ');
} else if ((cmdline = getenv(bootargs)) == NULL) {
cmdline = ;
}
@@ -1533,6 +1540,7 @@ static int do_bootm_plan9(int flag, int argc, char * 
const argv[],
   bootm_headers_t *images)
 {
void (*entry_point)(void);
+   char *s;
 
if ((flag != 0)  (flag != BOOTM_STATE_OS_GO))
return 1;
@@ -1544,6 +1552,20 @@ static int do_bootm_plan9(int flag, int argc, char * 
const argv[],
}
 #endif
 
+   /* See README.plan9 */
+   s = getenv(confaddr);
+   if (s != NULL) {
+   char *confaddr = (char *)simple_strtoul(s, NULL, 16);
+
+   if (argc  2) {
+   copy_args(confaddr, argc-2, argv+2, '\n');
+   } else {
+   s = getenv(bootargs);
+   if (s != NULL)
+   strcpy(confaddr, s);
+   }
+   }
+
entry_point = (void (*)(void))images-ep;
 
printf(## Transferring control to Plan 9 (at address %08lx) ...\n,
diff --git a/doc/README.plan9 b/doc/README.plan9
new file mode 100644
index 000..2d3d0e0
--- /dev/null
+++ b/doc/README.plan9
@@ -0,0 +1,18 @@
+Plan 9 from Bell Labs kernel images require additional setup to pass
+configuration information to the kernel.  An environment variable named
+confaddr must be defined with the same value as CONFADDR (see mem.h).
+Use of this facility is optional, but should be preferable to manual
+configuration.
+
+When booting an image, arguments supplied to the bootm command will be
+copied to CONFADDR.  If no arguments are specified, the contents of the
+bootargs environment variable will be copied.
+
+If no command line arguments or bootargs are defined, CONFADDR is left
+uninitialized to permit manual configuration.  For example, PC-style
+configuration could be simulated by issuing a fatload in bootcmd:
+
+  # setenv bootcmd fatload mmc 0 $confaddr plan9.ini; ...; bootm
+
+Steven Stallion
+June 2013
-- 
1.7.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3] cmd_bootm: Add command line arguments to Plan 9

2013-06-10 Thread Steven Stallion
This patch introduces support for command line arguments to Plan 9.
Plan 9 generally dedicates a small region of kernel memory (known
as CONFADDR) for runtime configuration.  A new environment variable
named confaddr was introduced to indicate this location when copying
arguments.

Signed-off-by: Steven Stallion sstall...@gmail.com
---
Changes for v2:
   - Corrected checkpatch misses
   - Refactored common code to copy command line arguments
   - Added documentation for odd Plan 9 behavior
Changes for v3:
   - Corrected patch Subject

 common/cmd_bootm.c |   36 +---
 doc/README.plan9   |   18 ++
 2 files changed, 47 insertions(+), 7 deletions(-)
 create mode 100644 doc/README.plan9

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 05130b6..960a68f 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -1346,6 +1346,19 @@ static void fixup_silent_linux(void)
 }
 #endif /* CONFIG_SILENT_CONSOLE */
 
+#if defined(CONFIG_BOOTM_NETBSD) || defined(CONFIG_BOOTM_PLAN9)
+static void copy_args(char *dest, int argc, char * const argv[], char delim)
+{
+   int i;
+
+   for (i = 0; i  argc; i++) {
+   if (i  0)
+   *dest++ = delim;
+   strcpy(dest, argv[i]);
+   dest += strlen(argv[i]);
+   }
+}
+#endif
 
 /***/
 /* OS booting routines */
@@ -1408,13 +1421,7 @@ static int do_bootm_netbsd(int flag, int argc, char * 
const argv[],
for (i = 2, len = 0; i  argc; i += 1)
len += strlen(argv[i]) + 1;
cmdline = malloc(len);
-
-   for (i = 2, len = 0; i  argc; i += 1) {
-   if (i  2)
-   cmdline[len++] = ' ';
-   strcpy(cmdline[len], argv[i]);
-   len += strlen(argv[i]);
-   }
+   copy_args(cmdline, argc-2, argv+2, ' ');
} else if ((cmdline = getenv(bootargs)) == NULL) {
cmdline = ;
}
@@ -1533,6 +1540,7 @@ static int do_bootm_plan9(int flag, int argc, char * 
const argv[],
   bootm_headers_t *images)
 {
void (*entry_point)(void);
+   char *s;
 
if ((flag != 0)  (flag != BOOTM_STATE_OS_GO))
return 1;
@@ -1544,6 +1552,20 @@ static int do_bootm_plan9(int flag, int argc, char * 
const argv[],
}
 #endif
 
+   /* See README.plan9 */
+   s = getenv(confaddr);
+   if (s != NULL) {
+   char *confaddr = (char *)simple_strtoul(s, NULL, 16);
+
+   if (argc  2) {
+   copy_args(confaddr, argc-2, argv+2, '\n');
+   } else {
+   s = getenv(bootargs);
+   if (s != NULL)
+   strcpy(confaddr, s);
+   }
+   }
+
entry_point = (void (*)(void))images-ep;
 
printf(## Transferring control to Plan 9 (at address %08lx) ...\n,
diff --git a/doc/README.plan9 b/doc/README.plan9
new file mode 100644
index 000..2d3d0e0
--- /dev/null
+++ b/doc/README.plan9
@@ -0,0 +1,18 @@
+Plan 9 from Bell Labs kernel images require additional setup to pass
+configuration information to the kernel.  An environment variable named
+confaddr must be defined with the same value as CONFADDR (see mem.h).
+Use of this facility is optional, but should be preferable to manual
+configuration.
+
+When booting an image, arguments supplied to the bootm command will be
+copied to CONFADDR.  If no arguments are specified, the contents of the
+bootargs environment variable will be copied.
+
+If no command line arguments or bootargs are defined, CONFADDR is left
+uninitialized to permit manual configuration.  For example, PC-style
+configuration could be simulated by issuing a fatload in bootcmd:
+
+  # setenv bootcmd fatload mmc 0 $confaddr plan9.ini; ...; bootm
+
+Steven Stallion
+June 2013
-- 
1.7.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] cmd_bootm: Add command line arguments to Plan 9

2013-06-09 Thread Steven Stallion
On Sun, Jun 9, 2013 at 12:52 AM, Wolfgang Denk w...@denx.de wrote:
 This is basically the same code (with only irrelevant differences) as
 used by do_bootm_netbsd().  Can you please

 1) factor out this common code,  and
 2) documnt the behaviour
 ?

Will do.

 By the way: this patch still triggers two do not use assignment in if
 condition checkpoatch errors.  Please fix these, too.

Will do. I'll submit a v2 patch later this evening.

Thanks for being patient :-)

Steve
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] cmd_bootm: Add command line arguments to Plan 9

2013-06-08 Thread Steven Stallion
On Thu, Jun 6, 2013 at 4:41 PM, Steven Stallion sstall...@gmail.com wrote:
 This patch introduces support for command line arguments to Plan 9.
 Plan 9 generally dedicates a small region of kernel memory (known
 as CONFADDR) for runtime configuration.  A new environment variable
 named confaddr was introduced to indicate this location when copying
 arguments.

Apologies for the double post - it looks like the message had been
sitting in an mqueue waiting to resend.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] cmd_bootm: Add command line arguments to Plan 9

2013-06-08 Thread Steven Stallion
This patch introduces support for command line arguments to Plan 9.
Plan 9 generally dedicates a small region of kernel memory (known
as CONFADDR) for runtime configuration.  A new environment variable
named confaddr was introduced to indicate this location when copying
arguments.

Signed-off-by: Steven Stallion sstall...@gmail.com
---
 common/cmd_bootm.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 05130b6..5c62271 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -1533,6 +1533,7 @@ static int do_bootm_plan9(int flag, int argc, char * 
const argv[],
   bootm_headers_t *images)
 {
void (*entry_point)(void);
+   char *s;
 
if ((flag != 0)  (flag != BOOTM_STATE_OS_GO))
return 1;
@@ -1544,6 +1545,24 @@ static int do_bootm_plan9(int flag, int argc, char * 
const argv[],
}
 #endif
 
+   if ((s = getenv(confaddr)) != NULL) {
+   char *confaddr = (char *)simple_strtoul(s, NULL, 16);
+
+   if (argc  2) {
+   int i;
+
+   s = confaddr;
+   for (i = 2; i  argc; i++) {
+   if (i  2)
+   *s++ = '\n';
+   strcpy(s, argv[i]);
+   s += strlen(argv[i]);
+   }
+   } else if ((s = getenv(bootargs)) != NULL) {
+   strcpy(confaddr, s);
+   }
+   }
+
entry_point = (void (*)(void))images-ep;
 
printf(## Transferring control to Plan 9 (at address %08lx) ...\n,
-- 
1.7.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] cmd_bootm: Add command line arguments to Plan 9

2013-06-07 Thread Steven Stallion
On Fri, Jun 7, 2013 at 1:16 AM, Wolfgang Denk w...@denx.de wrote:

 In message CAGGHmKHmLAd_85SgHyC=
 ceumhu8u4enqyj3wt3rqyvdzatw...@mail.gmail.com you wrote:
 
   Please make this code configurable, so that people who never intend to
   use Plan 9 do not suffer from the increased code size.
 
  This is already done, if you look at the do_bootm_plan9 function, you'll
  see it is guarded by CONFIG_BOOTM_PLAN9. These changes only affect users
  that are booting Plan 9.

 I see.  Hm... I wonder which version of U-Boot your patch is against?
 The line numbers in your patch are off by at least 126 lines, and
 common/cmd_bootm.c has not been touched for many months ?


That's odd. I just double checked and my repository seems to be in sync.
I'll do some poking around to make sure I didn't miss something.

  ERROR: do not use assignment in if condition
 
  I noticed the errors, however the style and format of my changes are the
  same as those in other functions in cmd_bootm; do_bootm_netbsd probably
  being the closest example. I did not watch to introduce style drift.

 But we should not add more bad style code either.  Feel free to send a
 cleanup patch for the existing code parts.  In any case, do not add
 more such stuff.


Will do.

 It's as unlimited as you have memory :-) That said, adjacent pages to
  CONFADDR are zeroed out at boot, so there is no possibility of overflow
  once you branch to the kernel.

 Adjacent pages being zeroed - that means that you _are_ actually
 limited to one page size?

   Why do you make this (completely undocumented!!!) distinction between
   bootm being used with one or more arguments?  Why can you not
   simply _always_ use bootargs ?
 
  This is to support passing arguments via bootm. This behavior is
 consistent
  with NetBSD.

 ...which I consider a really weird desiign that IMO should not be
 followed without need.

 If you decide to do so nevertheless, then please

 1) document the behaviour
 2) factor out the common code instead of copying it


Hmm. Are you arguing against supporting command line arguments to bootm, or
that bootm should copy these arguments to bootargs prior to boot? This has
actually been very useful to test changes without having to update my
bootargs environment variable.

Where is the best place to document the behavior, README? The code looks as
though it's common, but unfortunately it's not. plan9.ini(8) requires that
arguments be terminated with a newline, the NetBSD loader uses spaces.

  What if the user did not set the confaddr environment variable?
   Then the memory reagion there is left uninitialized?  Does this not
   cause undefined behaviour when booting Plan 9?
 
  There are checks which account for uninitialized memory at boot. It's
 ugly,
  but it's how the OS deals with configuration. I don't like it either.

 How does it detect if there are valid arguments (versus random crap)
 in the memory range starting at confaddr?  I can see no checksum or
 similar?


Some ports (such as OMAP) will stop once it encounters the first non-ASCII
character. In general, the parsing for the configuration is fairly strict
and is only a small risk if a user configures the system incorrectly.

There is also something subtle in not specifying confaddr (or bootargs for
that matter). Many ports support loading configuration from a FAT file
system. U-Boot would be no different.

I realize this probably seems very foreign. Plan 9 is somewhat unique in
that it relies on a variety of loaders. Some are more intelligent than
others, but in the end, configuration has to be dropped in a known location
for the kernel to parse. There is no second-stage loader, so passing a
pointer has limited utility since the code to parse the config happens
after the MMU has been initialized.

 And how does Plan 9 learn where to find this date? I cannot see how
   you pass this address on to Plan 9?
 
  Like most things in Plan 9, it is a compiled offset (defined in mem.h).
  CONFADDR is fixed, so as long as the configuration is dumped to the right
  location (which can change between kernels), it will work.

 But then makes no sense to use a confaddr environment variable for
 this - the user has no real choice of setting this variable: either it
 matches the fixed CONFADDR value, in which case it works, or it is
 different, in which case it will silently fail.  This is bad.
 I think you should use a CONFIG_SYS_CONFADDR constant instead.


Ah, this is another subtlety. CONFADDR can change depending on the kernel
you are booting. Some ports use as much as 64K to store configuration.
Having to recompile U-Boot and reflash based on a kernel change would add a
lot of complication and frustration. Having confaddr also makes it somewhat
simpler to write a generic boot command which will do a fatload rather than
use bootargs.

 Even worse - this code is actually pretty dangerous: confaddr is
   neither a reserved name, nor is it in any way exotic enough to be sure
   nobody else would 

Re: [U-Boot] [PATCH] cmd_bootm: Add command line arguments to Plan 9

2013-06-07 Thread Steven Stallion
On Fri, Jun 7, 2013 at 2:57 PM, Wolfgang Denk w...@denx.de wrote:
 Dear Steven,

 In message 
 cagghmkh2nsdoqjbrucb5xjsjcuoyfco6cz8msjtxdshh6p6...@mail.gmail.com you 
 wrote:

 Hmm. Are you arguing against supporting command line arguments to bootm, or
 that bootm should copy these arguments to bootargs prior to boot? This has
 actually been very useful to test changes without having to update my
 bootargs environment variable.

 bootm has a well-known an documented API: it takes up to three
 arguments: kernel address, ramdisk address, and device tree address.
 Nothing else.

Is there a reason that this should only be used by Linux? The changes
I have submitted follow the same behavior as NetBSD. VxWorks and QNX
also have their own quirks that don't follow the same path/usage as
Linux.

 If you want to implement a different interface, this should at least
 be documented - but then I doubt if this should be named bootm.  If
 I use it with 3 arguments, I expect the well-known behaviour, on all
 systems.

The usage seems to indicate this is a valid approach:

Usage:
bootm [addr [arg ...]]

If this is such a contentious change, I'm happy to drop it. I was
following the NetBSD approach since it was the most similar. It would
be a shame to let it go - it's useful.

 Some ports (such as OMAP) will stop once it encounters the first non-ASCII
 character. In general, the parsing for the configuration is fairly strict
 and is only a small risk if a user configures the system incorrectly.

 Hm.  This is just a subterfuge for there is no security at all, and
 you are invoking undefined behaviour ...

This would only happen if a user did not configure the loader appropriately.

 There is also something subtle in not specifying confaddr (or bootargs for
 that matter). Many ports support loading configuration from a FAT file
 system. U-Boot would be no different.

 I don't see what this has to do with it?

Plan 9 was traditionally loaded from FAT on PC architectures. Much of
that support still exists today. Typically, a small FAT partition
exists, which houses the kernel and the configuration (plan9.ini).
With U-Boot, to emulate this behavior a fatload would be issued to
copy the file to the proper location. This allows users to modify
their configuration and reboot without having to drop into the U-Boot
shell.

If do_plan9_bootm writes a NUL byte if no bootargs are defined, this
would break the fatload method.

 Ah, this is another subtlety. CONFADDR can change depending on the kernel
 you are booting. Some ports use as much as 64K to store configuration.
 Having to recompile U-Boot and reflash based on a kernel change would add a
 lot of complication and frustration. Having confaddr also makes it somewhat
 simpler to write a generic boot command which will do a fatload rather than
 use bootargs.

 You have no way to check for valid data, and you have no way to know
 the correct address, because it is neither fixed nor known to both
 the producer and the consumer?  I'm sorry, but this is crap.

It's known to both the producer and consumer, but can change during
development. Having it compiled in also means that you do not have
quick access to the value to use for a fatload, though this is a minor
annoyance.

 Is there a better method to allow confaddr to change without forcing a
 re-compile, or duplication if a user decides to do a fatload rather than
 define bootargs?

 I'm sorry, but it appears this design is completely borked, so how
 should I answer this?  If you have no way to know the correct
 adddress, and the consumer has no way to verify the data it recives,
 it's all just trial and error.  Not exactly a robust design, that is.

It's a known address for known kernels but needs to have the
flexibility to change without a recompile. Personal feelings aside,
this is how the kernel handles configuration at boot - I can only do
so much.

I very much want these changes (or an acceptable version of them) to
go upstream. Most users tend to just hack up U-Boot for the boards
they use and maintain private forks, but I would like to see better
support in both directions. I'm happy to keep a fork, but these
changes do not seem onerous, especially given that other operating
systems that are already supported follow this exact behavior.

Cheers,

Steve
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] README: Document support for Plan 9

2013-06-06 Thread Steven Stallion
Signed-off-by: Steven Stallion sstall...@gmail.com
---
 README |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README b/README
index b1b3e17..9782bb8 100644
--- a/README
+++ b/README
@@ -4636,9 +4636,9 @@ details; basically, the header defines the following 
image properties:
 
 * Target Operating System (Provisions for OpenBSD, NetBSD, FreeBSD,
   4.4BSD, Linux, SVR4, Esix, Solaris, Irix, SCO, Dell, NCR, VxWorks,
-  LynxOS, pSOS, QNX, RTEMS, INTEGRITY;
+  LynxOS, pSOS, QNX, RTEMS, INTEGRITY, Plan 9 from Bell Labs;
   Currently supported: Linux, NetBSD, VxWorks, QNX, RTEMS, LynxOS,
-  INTEGRITY).
+  INTEGRITY, Plan 9 from Bell Labs).
 * Target CPU Architecture (Provisions for Alpha, ARM, AVR32, Intel x86,
   IA64, MIPS, NDS32, Nios II, PowerPC, IBM S390, SuperH, Sparc, Sparc 64 Bit;
   Currently supported: ARM, AVR32, Intel x86, MIPS, NDS32, Nios II, PowerPC).
-- 
1.7.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] cmd_bootm: Add command line arguments to Plan 9

2013-06-06 Thread Steven Stallion
This patch introduces support for command line arguments to Plan 9.
Plan 9 generally dedicates a small region of kernel memory (known
as CONFADDR) for runtime configuration.  A new environment variable
named confaddr was introduced to indicate this location when copying
arguments.

Signed-off-by: Steven Stallion sstall...@gmail.com
---
 common/cmd_bootm.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 05130b6..5c62271 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -1533,6 +1533,7 @@ static int do_bootm_plan9(int flag, int argc, char * 
const argv[],
   bootm_headers_t *images)
 {
void (*entry_point)(void);
+   char *s;
 
if ((flag != 0)  (flag != BOOTM_STATE_OS_GO))
return 1;
@@ -1544,6 +1545,24 @@ static int do_bootm_plan9(int flag, int argc, char * 
const argv[],
}
 #endif
 
+   if ((s = getenv(confaddr)) != NULL) {
+   char *confaddr = (char *)simple_strtoul(s, NULL, 16);
+
+   if (argc  2) {
+   int i;
+
+   s = confaddr;
+   for (i = 2; i  argc; i++) {
+   if (i  2)
+   *s++ = '\n';
+   strcpy(s, argv[i]);
+   s += strlen(argv[i]);
+   }
+   } else if ((s = getenv(bootargs)) != NULL) {
+   strcpy(confaddr, s);
+   }
+   }
+
entry_point = (void (*)(void))images-ep;
 
printf(## Transferring control to Plan 9 (at address %08lx) ...\n,
-- 
1.7.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2] image: Add support for Plan 9

2013-03-20 Thread Steven Stallion
Signed-off-by: Steven Stallion sstall...@gmail.com
Cc: Tom Rini tr...@ti.com
---
This patch adds support for Plan 9 from Bell Labs kernel images.

Changes for v2:
   - Combined previous patches for image and bootm

 common/cmd_bootm.c| 39 +++
 common/image.c|  1 +
 include/config_defaults.h |  1 +
 include/image.h   |  1 +
 4 files changed, 42 insertions(+)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 5d2ce00..7438469 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -128,6 +128,9 @@ static boot_os_fn do_bootm_rtems;
 #if defined(CONFIG_BOOTM_OSE)
 static boot_os_fn do_bootm_ose;
 #endif
+#if defined(CONFIG_BOOTM_PLAN9)
+static boot_os_fn do_bootm_plan9;
+#endif
 #if defined(CONFIG_CMD_ELF)
 static boot_os_fn do_bootm_vxworks;
 static boot_os_fn do_bootm_qnxelf;
@@ -154,6 +157,9 @@ static boot_os_fn *boot_os[] = {
 #if defined(CONFIG_BOOTM_OSE)
[IH_OS_OSE] = do_bootm_ose,
 #endif
+#if defined(CONFIG_BOOTM_PLAN9)
+   [IH_OS_PLAN9] = do_bootm_plan9,
+#endif
 #if defined(CONFIG_CMD_ELF)
[IH_OS_VXWORKS] = do_bootm_vxworks,
[IH_OS_QNX] = do_bootm_qnxelf,
@@ -1628,6 +1634,39 @@ static int do_bootm_ose(int flag, int argc, char * const 
argv[],
 }
 #endif /* CONFIG_BOOTM_OSE */
 
+#if defined(CONFIG_BOOTM_PLAN9)
+static int do_bootm_plan9(int flag, int argc, char * const argv[],
+  bootm_headers_t *images)
+{
+   void (*entry_point)(void);
+
+   if ((flag != 0)  (flag != BOOTM_STATE_OS_GO))
+   return 1;
+
+#if defined(CONFIG_FIT)
+   if (!images-legacy_hdr_valid) {
+   fit_unsupported_reset(Plan 9);
+   return 1;
+   }
+#endif
+
+   entry_point = (void (*)(void))images-ep;
+
+   printf(## Transferring control to Plan 9 (at address %08lx) ...\n,
+   (ulong)entry_point);
+
+   bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+
+   /*
+* Plan 9 Parameters:
+*   None
+*/
+   (*entry_point)();
+
+   return 1;
+}
+#endif /* CONFIG_BOOTM_PLAN9 */
+
 #if defined(CONFIG_CMD_ELF)
 static int do_bootm_vxworks(int flag, int argc, char * const argv[],
 bootm_headers_t *images)
diff --git a/common/image.c b/common/image.c
index 6afbb40..60c2127 100644
--- a/common/image.c
+++ b/common/image.c
@@ -108,6 +108,7 @@ static const table_entry_t uimage_os[] = {
 #endif
{   IH_OS_NETBSD,   netbsd,   NetBSD,   },
{   IH_OS_OSE,  ose,  Enea OSE, },
+   {   IH_OS_PLAN9,plan9,Plan 9,   },
{   IH_OS_RTEMS,rtems,RTEMS,},
{   IH_OS_U_BOOT,   u-boot,   U-Boot,   },
 #if defined(CONFIG_CMD_ELF) || defined(USE_HOSTCC)
diff --git a/include/config_defaults.h b/include/config_defaults.h
index d023c63..567b46c 100644
--- a/include/config_defaults.h
+++ b/include/config_defaults.h
@@ -12,6 +12,7 @@
 /* Support bootm-ing different OSes */
 #define CONFIG_BOOTM_LINUX 1
 #define CONFIG_BOOTM_NETBSD 1
+#define CONFIG_BOOTM_PLAN9 1
 #define CONFIG_BOOTM_RTEMS 1
 
 #define CONFIG_GZIP 1
diff --git a/include/image.h b/include/image.h
index 8e285f9..4ad0e6b 100644
--- a/include/image.h
+++ b/include/image.h
@@ -84,6 +84,7 @@
 #define IH_OS_UNITY20  /* Unity OS */
 #define IH_OS_INTEGRITY21  /* INTEGRITY*/
 #define IH_OS_OSE  22  /* OSE  */
+#define IH_OS_PLAN923  /* Plan 9   */
 
 /*
  * CPU Architecture Codes (supported by Linux)
-- 
1.8.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] bootm: Add support for Plan 9

2013-03-18 Thread Steven Stallion
From 902b728b8bcacecf9e2ea7854cc1e3777c2fd4e3 Mon Sep 17 00:00:00 2001

Apologies for the second patch; I did not realize at the time that
modifications were needed for bootm to function correctly.

---
 common/cmd_bootm.c| 39 +++
 include/config_defaults.h |  1 +
 2 files changed, 40 insertions(+)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 5d2ce00..7438469 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -128,6 +128,9 @@ static boot_os_fn do_bootm_rtems;
 #if defined(CONFIG_BOOTM_OSE)
 static boot_os_fn do_bootm_ose;
 #endif
+#if defined(CONFIG_BOOTM_PLAN9)
+static boot_os_fn do_bootm_plan9;
+#endif
 #if defined(CONFIG_CMD_ELF)
 static boot_os_fn do_bootm_vxworks;
 static boot_os_fn do_bootm_qnxelf;
@@ -154,6 +157,9 @@ static boot_os_fn *boot_os[] = {
 #if defined(CONFIG_BOOTM_OSE)
  [IH_OS_OSE] = do_bootm_ose,
 #endif
+#if defined(CONFIG_BOOTM_PLAN9)
+ [IH_OS_PLAN9] = do_bootm_plan9,
+#endif
 #if defined(CONFIG_CMD_ELF)
  [IH_OS_VXWORKS] = do_bootm_vxworks,
  [IH_OS_QNX] = do_bootm_qnxelf,
@@ -1628,6 +1634,39 @@ static int do_bootm_ose(int flag, int argc, char *
const argv[],
 }
 #endif /* CONFIG_BOOTM_OSE */

+#if defined(CONFIG_BOOTM_PLAN9)
+static int do_bootm_plan9(int flag, int argc, char * const argv[],
+   bootm_headers_t *images)
+{
+ void (*entry_point)(void);
+
+ if ((flag != 0)  (flag != BOOTM_STATE_OS_GO))
+ return 1;
+
+#if defined(CONFIG_FIT)
+ if (!images-legacy_hdr_valid) {
+ fit_unsupported_reset(Plan 9);
+ return 1;
+ }
+#endif
+
+ entry_point = (void (*)(void))images-ep;
+
+ printf(## Transferring control to Plan 9 (at address %08lx) ...\n,
+ (ulong)entry_point);
+
+ bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+
+ /*
+ * Plan 9 Parameters:
+ *   None
+ */
+ (*entry_point)();
+
+ return 1;
+}
+#endif /* CONFIG_BOOTM_PLAN9 */
+
 #if defined(CONFIG_CMD_ELF)
 static int do_bootm_vxworks(int flag, int argc, char * const argv[],
  bootm_headers_t *images)
diff --git a/include/config_defaults.h b/include/config_defaults.h
index d023c63..567b46c 100644
--- a/include/config_defaults.h
+++ b/include/config_defaults.h
@@ -12,6 +12,7 @@
 /* Support bootm-ing different OSes */
 #define CONFIG_BOOTM_LINUX 1
 #define CONFIG_BOOTM_NETBSD 1
+#define CONFIG_BOOTM_PLAN9 1
 #define CONFIG_BOOTM_RTEMS 1

 #define CONFIG_GZIP 1
-- 
1.8.2
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] image: Add support for Plan 9

2013-03-17 Thread Steven Stallion
From 2c6086251774e6dcdba8ee9a83c8b5cbe2a643f4 Mon Sep 17 00:00:00 2001

This patch adds support for Plan 9 to image.c; primarily a cosmetic change
when booting Plan 9 kernels using U-Boot.

---
 common/image.c  | 1 +
 include/image.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/common/image.c b/common/image.c
index 6afbb40..60c2127 100644
--- a/common/image.c
+++ b/common/image.c
@@ -108,6 +108,7 @@ static const table_entry_t uimage_os[] = {
 #endif
  { IH_OS_NETBSD, netbsd, NetBSD, },
  { IH_OS_OSE, ose, Enea OSE, },
+ { IH_OS_PLAN9, plan9, Plan 9, },
  { IH_OS_RTEMS, rtems, RTEMS, },
  { IH_OS_U_BOOT, u-boot, U-Boot, },
 #if defined(CONFIG_CMD_ELF) || defined(USE_HOSTCC)
diff --git a/include/image.h b/include/image.h
index 8e285f9..4ad0e6b 100644
--- a/include/image.h
+++ b/include/image.h
@@ -84,6 +84,7 @@
 #define IH_OS_UNITY 20 /* Unity OS */
 #define IH_OS_INTEGRITY 21 /* INTEGRITY */
 #define IH_OS_OSE 22 /* OSE */
+#define IH_OS_PLAN9 23 /* Plan 9 */

 /*
  * CPU Architecture Codes (supported by Linux)
-- 
1.8.2
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot