X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Finit_src%2Fmain.c;h=c18e5f8c0cdcec30d7cdb96be222ca9b5717de9b;hb=d0b4559f2936f6d9f06be0f7c3c51527a480ec0d;hp=55c48012a105e701536361ed38a94136309e6c50;hpb=a048f2a350824bb7e0b8191bcf16addd1543b882;p=tpg%2Facess2.git diff --git a/Usermode/Applications/init_src/main.c b/Usermode/Applications/init_src/main.c index 55c48012..c18e5f8c 100644 --- a/Usermode/Applications/init_src/main.c +++ b/Usermode/Applications/init_src/main.c @@ -2,35 +2,52 @@ * Acess2 System Init Task */ #include +#include +#include +//#include "common.h" // === CONSTANTS === -#define NULL ((void*)0) +#define NUM_TERMS 4 #define DEFAULT_TERMINAL "/Devices/VTerm/0" -#define DEFAULT_SHELL "/Acess/CLIShell" +#define DEFAULT_SHELL "/Acess/SBin/login" + +#define ARRAY_SIZE(x) ((sizeof(x))/(sizeof((x)[0]))) + +// === PROTOTYPES === // === CODE === /** * \fn int main(int argc, char *argv[]) + * \brief Entrypoint */ int main(int argc, char *argv[]) { int tid; - open(DEFAULT_TERMINAL, OPENFLAG_READ); // Stdin - open(DEFAULT_TERMINAL, OPENFLAG_WRITE); // Stdout - open(DEFAULT_TERMINAL, OPENFLAG_WRITE); // Stderr + int i; + char termpath[sizeof(DEFAULT_TERMINAL)] = DEFAULT_TERMINAL; + char *child_argv[2] = {DEFAULT_SHELL, 0}; - write(1, 13, "Hello, World!"); + // - Parse init script - tid = clone(CLONE_VM, 0); - if(tid == 0) - { - execve(DEFAULT_SHELL, NULL, NULL); - for(;;) __asm__ __volatile__("hlt"); + // - Start virtual terminals + for( i = 0; i < NUM_TERMS; i++ ) + { + tid = clone(CLONE_VM, 0); + if(tid == 0) + { + termpath[sizeof(DEFAULT_TERMINAL)-2] = '0' + i; + + open(termpath, OPENFLAG_READ); // Stdin + open(termpath, OPENFLAG_WRITE); // Stdout + open(termpath, OPENFLAG_WRITE); // Stderr + execve(DEFAULT_SHELL, child_argv, NULL); + for(;;) sleep(); + } } - __asm__ __volatile__("xchg %%bx, %%bx"::"a"(tid)); - + // TODO: Implement message watching for(;;) sleep(); return 42; } +