Permalink
Browse files

added init process

  • Loading branch information...
1 parent 96afcfb commit 67c70099560bb7d901d15a820a64dd056d0ba455 @fdomig committed Feb 2, 2012
Showing with 156 additions and 0 deletions.
  1. +44 −0 applications/ottos_init/app.cmd
  2. +42 −0 applications/ottos_init/boot.asm
  3. +70 −0 applications/ottos_init/src/init.c
@@ -0,0 +1,44 @@
+////////////////////////////////////////////////////////
+//
+// Linker command file for a Task for the Ottos-Kernel
+//
+
+-stack 0x00002000
+-heap 0x00004000
+
+MEMORY
+{
+ virtual_memory: ORIGIN 0x00020000 LENGTH = 0x01000000
+ stack_memory: ORIGIN 0x10000000 LENGTH = 0x00002000
+ sysmem_memory: ORIGIN 0x10002000 LENGTH = 0x00004000
+
+}
+
+SECTIONS
+{
+ ORDER
+ .text > virtual_memory {
+ boot.obj
+ *(.text)
+ }
+ .bss > virtual_memory
+ .const > virtual_memory
+ .cinit > virtual_memory
+ .pinit > virtual_memory
+ .cio > virtual_memory
+ .switch > virtual_memory
+ .far > virtual_memory
+ .data > virtual_memory
+ .switch > virtual_memory
+ .init_array > virtual_memory
+
+ .stack > stack_memory {
+ systemStack = .;
+ }
+
+ .sysmem > sysmem_memory {
+ sysmem = .;
+ }
+
+
+}
@@ -0,0 +1,42 @@
+;***************************************************************
+;* this is an arm-function
+;***************************************************************
+
+ .armfunc _c_int00
+ .global _c_int00
+
+;***************************************************************
+;* TI includes
+;***************************************************************
+
+ .asg __args_main, ARGS_MAIN_RTN
+ .global ARGS_MAIN_RTN
+ .global __TI_auto_init
+
+;***************************************************************
+;* Included addresses from the linker
+;***************************************************************
+
+ .global systemStack
+
+;***************************************************************
+;* CONSTANTS USED BY THIS MODULE
+;***************************************************************
+
+c_r13_system .long systemStack
+
+;***************************************************************
+;* FUNCTION DEF: _c_int00
+;***************************************************************
+
+_c_int00: .asmfunc
+
+ ; Perform all the required initilizations:
+ ; - Process BINIT Table
+ ; - Perform C auto initialization
+ ; - Call global constructors)
+ BL __TI_auto_init
+
+ ; CALL APPLICATION
+ BL ARGS_MAIN_RTN
+.end
@@ -0,0 +1,70 @@
+/* init.c
+ *
+ * Copyright (c) 2011 The ottos_init project.
+ *
+ * This work is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This work 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 Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *
+ * Created on: 02.02.2012
+ * Author: Franziskus Domig <fdomig@gmail.com>
+ */
+
+#include <ottos/types.h>
+
+#include <api/proc.h>
+#include <api/system.h>
+#include <api/io.h>
+
+#define APP_WEATHER_SERVICE "/bin/weather_service"
+#define APP_WEATHER_LOGGER "/bin/weather_logger"
+#define APP_WEATHER_UI "/bin/weather_ui"
+#define APP_TTY "/bin/ottos_tty"
+
+pid_t start_app(const char* app) {
+ return (pid_t) sys_execute(1, FALSE, app, 0, NULL);
+}
+
+void run_forever() {
+ pid_t tty_pid = start_app(APP_TTY);
+
+ do {
+ pinfo_t tty_info;
+
+ // is the tty process running?
+ if (0 == pinfo_for(tty_pid, &tty_info)) {
+ print("tty is not running, restarting ...\n\r");
+ tty_pid = start_app(APP_TTY);
+ }
+
+ // hand over to another process
+ sys_yield();
+
+ } while (1);
+}
+
+
+int main(int argc, char** argv) {
+
+ // basic processes
+ // start_app(APP_WEATHER_SERVICE);
+ // start_app(APP_WEATHER_LOGGER);
+ // start_app(APP_WEATHER_UI);
+
+ // start terminal and check in an endless loop if tty is running
+ run_forever();
+
+ pexit(0);
+ return 0;
+}

0 comments on commit 67c7009

Please sign in to comment.