int main( void ) { FILE* fp; // Initialize platform first if( platform_init() != PLATFORM_OK ) { // This should never happen while( 1 ); } // Initialize device manager dm_init(); // Register the ROM filesystem dm_register( romfs_init() ); // Register the MMC filesystem dm_register( mmcfs_init() ); // Register the remote filesystem dm_register( remotefs_init() ); // Autorun: if "autorun.lua" is found in the file system, run it first if( ( fp = fopen( FS_AUTORUN, "r" ) ) != NULL ) { fclose( fp ); char* lua_argv[] = { "lua", FS_AUTORUN, NULL }; lua_main( 2, lua_argv ); } #ifdef ELUA_BOOT_RPC boot_rpc(); #else // Run the shell if( shell_init() == 0 ) { printf( "Unable to initialize the eLua shell!\n" ); // Start Lua directly char* lua_argv[] = { "lua", NULL }; lua_main( 1, lua_argv ); } else shell_start(); #endif // #ifdef ELUA_BOOT_RPC #ifdef ELUA_SIMULATOR hostif_exit(0); return 0; #else while( 1 ); #endif }
int main( void ) { int i; FILE* fp; // Initialize platform first if( platform_init() != PLATFORM_OK ) { // This should never happen while( 1 ); } // Initialize device manager dm_init(); // Register the ROM filesystem romfs_init(); // Register the MMC filesystem mmcfs_init(); // Register the Semihosting filesystem semifs_init(); // Register the remote filesystem remotefs_init(); // Register NIFFS nffs_init(); // Search for autorun files in the defined order and execute the 1st if found for( i = 0; i < sizeof( boot_order ) / sizeof( *boot_order ); i++ ) { if( ( fp = fopen( boot_order[ i ], "r" ) ) != NULL ) { fclose( fp ); char* lua_argv[] = { (char *)"lua", (char *)boot_order[i], NULL }; lua_main( 2, lua_argv ); break; // autoruns only the first found } } #ifdef ELUA_BOOT_RPC boot_rpc(); #else // Run the shell if( shell_init() == 0 ) { // Start Lua directly char* lua_argv[] = { (char *)"lua", NULL }; lua_main( 1, lua_argv ); } else shell_start(); #endif // #ifdef ELUA_BOOT_RPC #ifdef ELUA_SIMULATOR hostif_exit(0); return 0; #else while( 1 ); #endif }