Kernel - Commenting changes only
[tpg/acess2.git] / Usermode / Applications / init_src / main.c
1 /*
2  * Acess2 System Init Task
3  */
4 #include <acess/sys.h>
5 #include <stdlib.h>
6 #include <stdio.h>
7 //#include "common.h"
8
9 // === CONSTANTS ===
10 #define NUM_TERMS       4
11 #define DEFAULT_TERMINAL        "/Devices/VTerm/0"
12 #define DEFAULT_SHELL   "/Acess/SBin/login"
13
14 #define ARRAY_SIZE(x)   ((sizeof(x))/(sizeof((x)[0])))
15
16 // === PROTOTYPES ===
17
18 // === CODE ===
19 /**
20  * \fn int main(int argc, char *argv[])
21  * \brief Entrypoint
22  */
23 int main(int argc, char *argv[])
24 {
25          int    tid;
26          int    i;
27         char    termpath[sizeof(DEFAULT_TERMINAL)] = DEFAULT_TERMINAL;
28         char    *child_argv[2] = {DEFAULT_SHELL, 0};
29         
30         // - Parse init script
31         
32         // - Start virtual terminals
33         for( i = 0; i < NUM_TERMS; i++ )
34         {               
35                 tid = _SysClone(CLONE_VM, 0);
36                 if(tid == 0)
37                 {
38                         termpath[sizeof(DEFAULT_TERMINAL)-2] = '0' + i;
39                         
40                         _SysOpen(termpath, OPENFLAG_READ);      // Stdin
41                         _SysOpen(termpath, OPENFLAG_WRITE);     // Stdout
42                         _SysOpen(termpath, OPENFLAG_WRITE);     // Stderr
43                         _SysExecVE(DEFAULT_SHELL, child_argv, NULL);
44                         for(;;) ;
45                 }
46         }
47         
48         // TODO: Implement message watching
49         for(;;)
50                 _SysWaitEvent(THREAD_EVENT_IPCMSG);
51         
52         return 42;
53 }
54

UCC git Repository :: git.ucc.asn.au