gonzui


Format: Advanced Search

t2ex/t2ex_source/kernel/sysmain/src/usermain_t2ex.cbare sourcepermlink (0.03 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T2EX Software Package
    4:  *
    5:  *    Copyright 2012 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2012/12/12.
   10:  *    Modified by T-Engine Forum at 2013/03/04.
   11:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/04.
   12:  *
   13:  *----------------------------------------------------------------------
   14:  */
   15: /*
   16:  * This software package is available for use, modification, 
   17:  * and redistribution in accordance with the terms of the attached 
   18:  * T-License 2.x.
   19:  * If you want to redistribute the source code, you need to attach 
   20:  * the T-License 2.x document.
   21:  * There's no obligation to publish the content, and no obligation 
   22:  * to disclose it to the TRON Forum if you have modified the 
   23:  * software package.
   24:  * You can also distribute the modified source code. In this case, 
   25:  * please register the modification to T-Kernel traceability service.
   26:  * People can know the history of modifications by the service, 
   27:  * and can be sure that the version you have inherited some 
   28:  * modification of a particular version or not.
   29:  *
   30:  *    http://trace.tron.org/tk/?lang=en
   31:  *    http://trace.tron.org/tk/?lang=ja
   32:  *
   33:  * As per the provisions of the T-License 2.x, TRON Forum ensures that 
   34:  * the portion of the software that is copyrighted by Ken Sakamura or 
   35:  * the TRON Forum does not infringe the copyrights of a third party.
   36:  * However, it does not make any warranty other than this.
   37:  * DISCLAIMER: TRON Forum and Ken Sakamura shall not be held
   38:  * responsible for any consequences or damages caused directly or
   39:  * indirectly by the use of this software package.
   40:  *
   41:  * The source codes in bsd_source.tar.gz in this software package are 
   42:  * derived from NetBSD or OpenBSD and not covered under T-License 2.x.
   43:  * They need to be changed or redistributed according to the 
   44:  * representation of each source header.
   45:  */
   46: 
   47: /*
   48:  *      usermain.c (usermain)
   49:  *      User Main (T2EX)
   50:  */
   51: 
   52: #include <basic.h>
   53: #include <stdlib.h>
   54: #include <stdio.h>
   55: #include <string.h>
   56: #include <tk/tkernel.h>
   57: #include <tm/tmonitor.h>
   58: 
   59: /* Device drivers */
   60: IMPORT ER ConsoleIO( INT ac, UB *av[] );
   61: IMPORT ER ClockDrv( INT ac, UB *av[] );
   62: IMPORT ER SysDiskDrv( INT ac, UB *av[] );
   63: IMPORT ER ScreenDrv( INT ac, UB *av[] );
   64: IMPORT ER KbPdDrv( INT ac, UB *av[] );
   65: IMPORT ER LowKbPdDrv( INT ac, UB *av[] );
   66: IMPORT ER NetDrv( INT ac, UB *av[] );
   67: 
   68: /* T2EX extension modules */
   69: IMPORT ER dt_main( INT ac, UB* av[] );
   70: IMPORT ER pm_main( INT ac, UB* av[] );
   71: IMPORT ER fs_main( INT ac, UB* av[] );
   72: IMPORT ER so_main( INT ac, UB* av[] );
   73: 
   74: /* Application program */
   75: IMPORT void appl_main(void);
   76: 
   77: /*
   78:  * Entry routine for the user application.
   79:  * At this point, Initialize and start the user application.
   80:  *
   81:  * Entry routine is called from the initial task for Kernel,
   82:  * so system call for stopping the task should not be issued
   83:  * from the contexts of entry routine.
   84:  * We recommend that:
   85:  * (1)'usermain()' only generates the user initial task.
   86:  * (2)initialize and start the user application by the user
   87:  * initial task.
   88:  */
   89: EXPORT  INT      usermain( void )
   90: {
   91:         ER     err;
   92: 
   93:         /* Start the device drivers */
   94: #ifdef DRV_CONSOLE
   95:         err = ConsoleIO(0, NULL);
   96:         tm_putstring(err >= E_OK ? "ConsoleIO - OK\n" : "ConsoleIO - ERR\n");
   97: #endif
   98: #ifdef DRV_CLOCK
   99:         err = ClockDrv(0, NULL);
  100:         tm_putstring(err >= E_OK ? "ClockDrv - OK\n" : "ClockDrv - ERR\n");
  101: #endif
  102: #ifdef DRV_SYSDISK
  103:         err = SysDiskDrv(0, NULL);
  104:         tm_putstring(err >= E_OK ? "SysDiskDrv - OK\n" : "SysDiskDrv - ERR\n");
  105: #endif
  106: #ifdef DRV_SCREEN
  107:         err = ScreenDrv(0, NULL);
  108:         tm_putstring(err >= E_OK ? "ScreenDrv - OK\n" : "ScreenDrv - ERR\n");
  109: #endif
  110: #ifdef DRV_KBPD
  111:         err = KbPdDrv(0, NULL);
  112:         tm_putstring(err >= E_OK ? "KbPdDrv - OK\n" : "KbPdDrv - ERR\n");
  113: #endif
  114: #ifdef DRV_LOWKBPD
  115:         err = LowKbPdDrv(0, NULL);
  116:         tm_putstring(err >= E_OK ? "LowKbPdDrv - OK\n" : "LowKbPdDrv - ERR\n");
  117: #endif
  118: #ifdef DRV_NET
  119:         err = NetDrv(0, NULL);
  120:         tm_putstring(err >= E_OK ? "NetDrv - OK\n" : "NetDrv - ERR\n");
  121: #endif
  122: 
  123:         /* Start the T2EX extension modules */
  124: #ifdef  USE_T2EX_DT
  125:         err = dt_main(0, NULL);
  126:         tm_putstring(err >= E_OK ? "dt_main(0) - OK\n":"dt_main(0) - ERR\n");
  127: #endif
  128: #ifdef  USE_T2EX_PM
  129:         err = pm_main(0, NULL);
  130:         tm_putstring(err >= E_OK ? "pm_main(0) - OK\n":"pm_main(0) - ERR\n");
  131: #endif
  132: #ifdef  USE_T2EX_FS
  133:         err = fs_main(0, NULL);
  134:         tm_putstring(err >= E_OK ? "fs_main(0) - OK\n":"fs_main(0) - ERR\n");
  135: #endif
  136: #ifdef  USE_T2EX_NET
  137:         err = so_main(0, NULL);
  138:         tm_putstring(err >= E_OK ? "so_main(0) - OK\n":"so_main(0) - ERR\n");
  139: #endif
  140: 
  141:         /* Initialize stdio */
  142:         libc_stdio_init();
  143: 
  144:         /* Start the T2EX application */
  145:         tm_putstring("*** T2EX Application program start !!\n");
  146:         appl_main();
  147: 
  148:         /* Shutdowm the T2EX extension modules */
  149: #ifdef  USE_T2EX_DT
  150:         err = dt_main(-1, NULL);
  151:         tm_putstring(err >= E_OK ? "dt_main(-1) - OK\n":"dt_main(-1) - ERR\n");
  152: #endif
  153: #ifdef  USE_T2EX_PM
  154:         err = pm_main(-1, NULL);
  155:         tm_putstring(err >= E_OK ? "pm_main(-1) - OK\n":"pm_main(-1) - ERR\n");
  156: #endif
  157: #ifdef  USE_T2EX_FS
  158:         err = fs_main(-1, NULL);
  159:         tm_putstring(err >= E_OK ? "fs_main(-1) - OK\n":"fs_main(-1) - ERR\n");
  160: #endif
  161: #ifdef  USE_T2EX_NET
  162:         err = so_main(-1, NULL);
  163:         tm_putstring(err >= E_OK ? "so_main(-1) - OK\n":"so_main(-1) - ERR\n");
  164: #endif
  165: 
  166:         /* Stop the device drivers */
  167: #ifdef DRV_NET
  168:         NetDrv(-1, NULL);
  169: #endif
  170: #ifdef DRV_LOWKBPD
  171:         LowKbPdDrv(-1, NULL);
  172: #endif
  173: #ifdef DRV_KBPD
  174:         KbPdDrv(-1, NULL);
  175: #endif
  176: #ifdef DRV_SCREEN
  177:         ScreenDrv(-1, NULL);
  178: #endif
  179: #ifdef DRV_SYSDISK
  180:         SysDiskDrv(-1, NULL);
  181: #endif
  182: #ifdef DRV_CLOCK
  183:         ClockDrv(-1, NULL);
  184: #endif
  185: #ifdef DRV_CONSOLE
  186:         ConsoleIO(-1, NULL);
  187: #endif
  188: 
  189:         return 0;
  190: }
  191: