summaryrefslogtreecommitdiff
path: root/bspinit.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2012-07-31 15:17:21 +1000
committerChris Johns <chrisj@rtems.org>2012-07-31 15:17:21 +1000
commit99bdd39271de093920b34d217a5a4b7f0a6f2e80 (patch)
treef73c646e5eb6173b63dacc4097794d5c8d1af274 /bspinit.c
parent328fbd26ed0213af7e328de105921f4eb7927e55 (diff)
Add ARM support. Cleaned up the waf support.
Adding ARM support has changed the architecture relocation interface. All architectures updated. Cleaned up the RTEMS waf support to only look for tools when the arch is being processed. Add filter support to allow a user to make sure a BSP is present or to remove BSPs that will not build. Added the Init support because ARM BSPs do not contain the support.
Diffstat (limited to 'bspinit.c')
-rw-r--r--bspinit.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/bspinit.c b/bspinit.c
new file mode 100644
index 0000000..9c50d03
--- /dev/null
+++ b/bspinit.c
@@ -0,0 +1,95 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <bsp.h>
+#include <bsp/bootcard.h>
+#ifdef RTEMS_NETWORKING
+ #include <rtems/rtems_bsdnet.h>
+#endif
+
+/*
+ * This routine calls main from a confdefs.h default Init task
+ * set up. The bootcard will provide the task argument as
+ * command line string (ASCIIZ).
+ */
+
+int main (int argc, char* argv[]);
+void Init (rtems_task_argument arg);
+
+void Init (rtems_task_argument arg)
+{
+ const char* boot_cmdline = *((const char**) arg);
+ char* cmdline = 0;
+ char* command;
+ int argc = 0;
+ char** argv = NULL;
+ int result = -124;
+
+ if (boot_cmdline)
+ {
+ cmdline = malloc (strlen (boot_cmdline) + 1);
+
+ if (cmdline)
+ {
+ strcpy (cmdline, boot_cmdline);
+
+ command = cmdline;
+
+ /*
+ * Break the line up into arguments with "" being ignored.
+ */
+ while (true)
+ {
+ command = strtok (command, " \t\r\n");
+ if (command == NULL)
+ break;
+ argc++;
+ command = '\0';
+ }
+
+ argv = calloc (argc, sizeof (char*));
+
+ if (argv)
+ {
+ int a;
+
+ command = cmdline;
+ argv[0] = command;
+
+ for (a = 1; a < argc; a++)
+ {
+ command += strlen (command) + 1;
+ argv[a] = command;
+ }
+ }
+ else
+ argc = 0;
+ }
+ }
+
+#ifdef RTEMS_NETWORKING
+ rtems_bsdnet_initialize_network ();
+#endif
+
+ result = main (argc, argv);
+
+ free (argv);
+ free (cmdline);
+
+ exit (result);
+}
+
+/*
+ * By making this a weak alias and a user can provide there own.
+ */
+
+void Init (rtems_task_argument arg) __attribute__ ((weak));