/*
    Demo.c, Copyright  (c) by ,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public Licence.
 
    A full copy of the GNU GPL is provided in the file COPYING found in the 
    development root of Topsy.
*/

#include "../Topsy/Topsy.h"
#include "../Topsy/Syscall.h"
#include "UserSupport.h"

#include "Demo.h"


void Testback1(ThreadArg arg)
{
  int      i = 0,arglen = 0,len=0;
  char*    argument = NULL;
  char     outputline[80];
  ThreadId tty;

  ioOpen(IO_CONSOLE, &tty);
  ioInit(tty);

  for (i=0; i<1000; i++)
  { /* NOP */
  }

  display(tty,"testback1 found args: \n");
  for (i=0; i<5; i++)
  {
    argument=((char**)arg)[i];
    if (argument==NULL)
      break;
    arglen=stringLength(argument);
    byteCopy((Address)(&outputline[len]),(Address)argument,arglen);
    len+=arglen;
    byteCopy((Address)(&outputline[len]),(Address)"|",1);
    len++;
  }
  byteCopy((Address)(&outputline[len]),(Address)"\n\0",2);

  display(tty,outputline);
  ioClose(tty);
}

void trap ()
{
  int* i = 5;

  *i = 1;
}

