コード例 #1
0
void main(void)
{
/* USER CODE BEGIN (3) */
	emif_SDRAMInit();
	sciInit();
	volatile int* sdram__base_ptr = (volatile int *)SDRAM_BASE_ADDRESS;
	int value = 0xAAAAFFFF;
	sci_printf("Writing:\r\n");

	while (sdram__base_ptr < (volatile int*)SDRAM_END_ADDREESS) {
		sci_printf("\tWriting 0x%X on address 0x%X \r\n", value, sdram__base_ptr);
		*sdram__base_ptr = value;
		sdram__base_ptr+=100000;
		value++;
	}
	sci_printf("Reading:\r\n");
	sdram__base_ptr = (volatile int *)SDRAM_BASE_ADDRESS;
	while (sdram__base_ptr < (volatile int*)SDRAM_END_ADDREESS) {
		value = *sdram__base_ptr;
		sci_printf("\tReading 0x%X on address 0x%X \r\n", value, sdram__base_ptr);
		sdram__base_ptr+=100000;
	}
	sci_printf("Done.\r\n");
	wait_forever();
/* USER CODE END */
}
コード例 #2
0
static void brcmstb_cpu_die(unsigned int cpu)
{
	extern void wait_forever(void);

	printk("CPU %d wait forever\n", cpu);
	
	wait_forever();
}
コード例 #3
0
ファイル: BKGDTEMP.C プロジェクト: Ced2911/umk3
/******************************************************************************
 Function: void candle_flame(void)

 By: David Schwartz

 Date: Feb 1995

 Parameters: None

 Returns: None

 Description:	animate the candles on the temple bkgd
******************************************************************************/
void candle_flame(void)
{
	process_sleep(randu(10));

	current_proc->pa9=a_candle_flame;
	framew(3+randu(2));

	wait_forever();
}
コード例 #4
0
		virtual void
		so_evt_start()
			{
				auto svc_proxy = m_svc_mbox->get_one< std::string >();

				auto c1 = svc_proxy.async( new msg_convert( 1 ) );
				auto c2 = svc_proxy.async( new msg_convert( 2 ) );

				compare_and_abort_if_missmatch(
						svc_proxy.wait_forever().sync_get( new msg_convert( 3 ) ),
						"3" );

				compare_and_abort_if_missmatch( c2.get(), "2" );
				compare_and_abort_if_missmatch( c1.get(), "1" );

				compare_and_abort_if_missmatch(
						svc_proxy.wait_forever().sync_get< msg_get_status >(),
						"ready" );

				m_svc_mbox->run_one().wait_forever().sync_get< msg_shutdown >();
			}
コード例 #5
0
ファイル: MKFRIEND.C プロジェクト: Ced2911/umk3
void friendship_complete(void)
{
	death_blow_complete();
	player_normpal();

#if 1
	/* sony add for memory */
	(current_proc->pa8)->oheap=player_heap_ptr;		// make sure and restore at end of animality
#endif

	wait_forever();
}
コード例 #6
0
ファイル: BKGDBELL.C プロジェクト: Ced2911/umk3
/******************************************************************************
 Function: void fall_down_bell_tower(void)

 By: David Schwartz

 Date: Mar 1995

 Parameters: None

 Returns: None

 Description:	die by bell tower fall
******************************************************************************/
void fall_down_bell_tower(void)
{
	current_proc->pdata.p_store7=(ADDRESS)current_proc->pa8;
	group_sound(9);
	clear_shadow_bit(current_proc->pa8);
	center_around_me();

	shake_a11(0x6,0xa);

	dallprc(PID_REPELL);

	(long)current_proc->a0=((SCX(600)-(current_proc->pa8)->oxpos.u.intpos)<<16)/0x50;
	(FUNC)current_proc->a6=bell_fall_scan;
	flight_call(current_proc->pa8,(long)current_proc->a0,-SCY(0x120000),SCY(0x6000),5,ANIM_KDOWN);
	stop_a8(current_proc->pa8);
	wait_forever();
}
コード例 #7
0
ファイル: MKFRIEND.C プロジェクト: Ced2911/umk3
void f_indian(void)
{
	OBJECT *obj,*ta8;
	void *animframe;

	//current_proc->pa9=a_ind_friend;
	get_char_ani(ANIM_TABLE2,ANIM_F1_FRIEND);

	other_ochar_sound(4,FT_ST);

	mframew_5;
	process_sleep(0x20);

	ta8=current_proc->pa8;
	current_proc->a10=(ADDRESS)current_proc->pa8;

	current_proc->a0=(ADDRESS)current_proc->pa9;
	animframe=(void*)get_char_ani(ANIM_TABLE2,ANIM_F2_FRIEND);		// get mk2game frame ptr
	current_proc->pa9=(void*)current_proc->a0;
	animframe=(void*)COMPUTE_ADDR(ta8->oheap,GET_LONG(animframe));

	gso_dmawnz(obj,(ADDRESS)animframe,ta8->oheap,0);
	alloc_cache((OIMGTBL*)animframe,ta8->oheap,obj);

	lineup_1pwm(obj,(OBJECT *)current_proc->a10);
	multi_adjust_xy(obj,-(SCX(0x70)),-SCY(0x100));
	insert_object(obj,&objlst);
	gravity_ani_ysize(SCY(0x20000),SCY(0x6000));
	shake_n_sound();

	if ( random()<0 )
	{
		p7_centered(txt_raiden1,160,SCY(0xf0)-14);
		p7_centered(txt_raiden2,160,SCY(0xf0));
	}
	else
	{
		p7_centered(txt_kano,160,SCY(0xf0));
	}

	current_proc->pa8=ta8;
	process_sleep(0x60);
	death_blow_complete();

	wait_forever();
}
コード例 #8
0
ファイル: MKFRIEND.C プロジェクト: Ced2911/umk3
void cute_lil_doggy(void)
{
	OBJECT *obj;

	current_proc->a10=(ADDRESS)current_proc->pa8;
	get_char_ani(ANIM_TABLE2,ANIM_F2_FRIEND);						// get ptr to anim table
	current_proc->pa9=COMPUTE_ADDR((current_proc->pa8)->oheap,GET_LONG(current_proc->pa9));	// get ptr to frame
	gso_dmawnz(obj,(ADDRESS)current_proc->pa9,(current_proc->pa8)->oheap,0);
	alloc_cache((OIMGTBL *)current_proc->pa9,(current_proc->pa8)->oheap,obj);

	if (((OBJECT *)current_proc->a10)->oflags & M_FLIPH)
	{
		obj->oxpos.u.intpos=SCRRGT+SCX(0x30)+SCX(0x30)+worldtlx.u.intpos-SCX(0x30);
		obj->oxvel.pos=-SCX(0x60000);
		flip_single(obj);
	}
	else
	{
		obj->oxpos.u.intpos=worldtlx.u.intpos-SCX(0x30);
		obj->oxvel.pos=SCX(0x60000);
	}

	/* cute3 */
	obj->oypos.u.intpos=ground_y-SCY(0x20);
	obj->ozval=100;
	insert_object(obj,&objlst);

	//current_proc->pa9=a_dog;
	get_char_ani(ANIM_TABLE2,ANIM_F2_FRIEND);
	init_anirate(3);
	do
	{
		next_anirate();
		process_sleep(1);

	} while (abs(worldtlx.u.intpos-obj->oxpos.u.intpos)<700);

	stop_a8(obj);

	wait_forever();
}
コード例 #9
0
ファイル: MKFRIEND.C プロジェクト: Ced2911/umk3
void pop_up_my_toy(void) 
{
	ADDRESS animframe;
	OBJECT *obj;

	tsound(0x92);
	shake_a11(6,6);
	takeover_him(r_scared_of_monkey);

	animframe=(ADDRESS)COMPUTE_ADDR((current_proc->pa8)->oheap,GET_LONG(current_proc->pa9));
	gso_dmawnz(obj,(ADDRESS)animframe,(current_proc->pa8)->oheap,0);
	alloc_cache((OIMGTBL *)animframe,(current_proc->pa8)->oheap,obj);
	obj->ozval=100;
	lineup_1pwm(obj,(OBJECT*)current_proc->a11);
	insert_object(obj,&objlst);

	framew(4);
	process_sleep(0x30);
	death_blow_complete();
	wait_forever();
}
コード例 #10
0
ファイル: MKFRIEND.C プロジェクト: Ced2911/umk3
//extern OIMGTBL *ostrich1;
void f_shang(void)
{
	OBJECT *obj=current_proc->pa8;
	void *animframe;

	CREATE(PID_BANI,end_friend_proc);
	tsound(0x8c);
	create_fx(FX_INVISO_POOF);

	process_sleep(8);

	set_inviso(current_proc->pa8);
	current_proc->a10=(ADDRESS)current_proc->pa8;

	get_char_ani(ANIM_TABLE2,ANIM_F1_FRIEND);
	animframe=(void*)COMPUTE_ADDR(obj->oheap,GET_LONG(current_proc->pa9));

	gso_dmawnz(obj,(ADDRESS)animframe,obj->oheap,0);
	alloc_cache((OIMGTBL *)animframe,obj->oheap,obj);

	obj->oxpos.u.intpos=((OBJECT*)current_proc->a10)->oxpos.u.intpos;
	obj->oypos.u.intpos=ground_y-SCY(0x20);
	insert_object(obj,&objlst);
	process_sleep(0x40);

	bounce();
	bounce();

	obj->oxvel.pos=SCX(0x30000);
	/* shang4 */
	current_proc->a10=5;
	do
	{
		bounce();
	}
	while(--current_proc->a10>0 );
	stop_a8(current_proc->pa8);
	wait_forever();
}
コード例 #11
0
ファイル: main.cpp プロジェクト: Theo917/DualBootPatcher
int main(int argc, char *argv[])
{
    enum {
        OPT_NO_LOG_FILE = 1000,
    };

    static struct option long_options[] = {
        { "no-log-file", no_argument, 0, OPT_NO_LOG_FILE },
        { "help",        no_argument, 0, 'h'             },
        { 0, 0, 0, 0 }
    };

    int opt;
    int long_index = 0;
    bool no_log_file = false;

    while ((opt = getopt_long(argc, argv, "h", long_options, &long_index)) != -1) {
        switch (opt) {
        case OPT_NO_LOG_FILE:
            no_log_file = true;
            break;

        case 'h':
            usage(stdout);
            return EXIT_SUCCESS;

        default:
            usage(stderr);
            return EXIT_FAILURE;
        }
    }

    // There should be one other argument
    if (argc - optind != 1) {
        usage(stderr);
        return EXIT_FAILURE;
    }

    umask(0);

    if (!mb::util::mkdir_recursive(MBBOOTUI_BASE_PATH, 0755)) {
        LOGE("%s: Failed to create directory: %s",
             MBBOOTUI_BASE_PATH, strerror(errno));
        return EXIT_FAILURE;
    }

    // Rotate log if it is too large
    struct stat sb;
    if (stat(MBBOOTUI_LOG_PATH, &sb) == 0 && sb.st_size > MAX_LOG_SIZE) {
        rename(MBBOOTUI_LOG_PATH, MBBOOTUI_LOG_PATH ".prev");
    }

    if (!no_log_file && !redirect_output_to_file(MBBOOTUI_LOG_PATH, 0600)) {
        return EXIT_FAILURE;
    }

    signal(SIGPIPE, SIG_IGN);

    // Set paths
    tw_resource_path = MBBOOTUI_THEME_PATH;
    tw_settings_path = MBBOOTUI_SETTINGS_PATH;
    tw_screenshots_path = MBBOOTUI_SCREENSHOTS_PATH;
    // Disallow custom themes, which could manipulate variables in such as way
    // as to execute malicious code
    tw_theme_zip_path = "";

    if (!detect_device()) {
        return EXIT_FAILURE;
    }

    // Check if device supports the boot UI
    if (!device->twOptions()->supported) {
        LOGW("Boot UI is not supported for the device");
        return EXIT_FAILURE;
    }

    // Load device configuration options
    load_device_config();
    load_other_config();

    log_startup();

    if (!extract_theme(argv[optind], MBBOOTUI_THEME_PATH,
                       device->twOptions()->theme)) {
        LOGE("Failed to extract theme");
        return EXIT_FAILURE;
    }

    // Connect to daemon
    if (!mbtool_connection.connect()) {
        LOGE("Failed to connect to mbtool");
        return EXIT_FAILURE;
    }
    mbtool_interface = mbtool_connection.interface();

    LOGV("Loading default values...");
    DataManager::SetDefaultValues();

    // Set daemon version
    std::string mbtool_version;
    mbtool_interface->version(&mbtool_version);
    DataManager::SetValue(TW_MBTOOL_VERSION, mbtool_version);

    LOGV("Loading graphics system...");
    if (gui_init() < 0) {
        LOGE("Failed to load graphics system");
        return EXIT_FAILURE;
    }

    LOGV("Loading resources...");
    gui_loadResources();

    LOGV("Checking for encryption...");
    char crypto_state[PROP_VALUE_MAX];
    mb::util::property_get(PROP_CRYPTO_STATE, crypto_state,
                           CRYPTO_STATE_DECRYPTED);

    if (strcmp(crypto_state, CRYPTO_STATE_ENCRYPTED) == 0) {
        LOGV("Data appears to be encrypted");

        int is_encrypted = 1;

        // Ask mbtool for password type
        std::string pw_type;
        if (!mbtool_interface->crypto_get_pw_type(&pw_type)) {
            LOGE("Failed to ask mbtool for the crypto password type");
            return EXIT_FAILURE;
        }

        // If password type is unknown, assume "password"
        if (pw_type.empty()) {
            LOGW("Crypto password type is unknown. Assuming 'password'");
            pw_type = "password";
        }

        // Try default password
        if (pw_type == "default") {
            bool ret;
            if (!mbtool_interface->crypto_decrypt("default_password", &ret)) {
                LOGE("Failed to ask mbtool to decrypt userdata");
                return EXIT_FAILURE;
            }

            if (ret) {
                LOGV("Successfully decrypted device with default password");
                is_encrypted = 0;
            } else {
                LOGW("Failed to decrypt device with default password despite "
                     "password type being 'default'");
                pw_type = "password";
            }
        }

        DataManager::SetValue(TW_IS_ENCRYPTED, is_encrypted);
        DataManager::SetValue(TW_CRYPTO_PWTYPE, pw_type);
        DataManager::SetValue(TW_CRYPTO_PASSWORD, "");
        DataManager::SetValue("tw_crypto_display", "");

        if (is_encrypted) {
            LOGV("Showing decrypt page first due to encrypted device");
            gui_startPage("decrypt", 1, 1);
        }

        if (DataManager::GetIntValue(TW_IS_ENCRYPTED) != 0) {
            LOGE("Decrypt page exited, but device is still encrypted");
            mb::util::property_set(PROP_CRYPTO_STATE, CRYPTO_STATE_ERROR);
            return EXIT_FAILURE;
        } else {
            LOGV("Decrypt page exited and device was successfully decrypted");
            mb::util::property_set(PROP_CRYPTO_STATE, CRYPTO_STATE_DECRYPTED);
        }
    }

    // Set ROM ID. This must happen after decryption or else the current ROM
    // will not be detected if it is a data-slot. mbtool's ROM detection code
    // doesn't fully trust the "ro.multiboot.romid" property and will do some
    // additional checks to ensure that the value is correct.
    std::string rom_id;
    mbtool_interface->get_booted_rom_id(&rom_id);
    if (rom_id.empty()) {
        LOGW("Could not determine ROM ID");
    }
    DataManager::SetValue(TW_ROM_ID, rom_id);

    LOGV("Loading user settings...");
    DataManager::ReadSettingsFile();

    LOGV("Loading language...");
    PageManager::LoadLanguage(DataManager::GetStrValue(TW_LANGUAGE));
    GUIConsole::Translate_Now();

    LOGV("Fixing time...");
    TWFunc::Fixup_Time_On_Boot();

    LOGV("Loading main UI...");
    //gui_start();
    gui_startPage("autoboot", 1, 0);

    // Exit action
    std::string exit_action;
    DataManager::GetValue(TW_EXIT_ACTION, exit_action);
    std::vector<std::string> args = mb::util::split(exit_action, ",");

    // Save settings
    DataManager::Flush();

    if (args.size() > 0) {
        if (args[0] == "reboot") {
            std::string reboot_arg;
            if (args.size() > 1) {
                reboot_arg = args[1];
            }
            bool result;
            mbtool_interface->reboot(reboot_arg, &result);
            wait_forever();
        } else if (args[0] == "shutdown") {
            bool result;
            mbtool_interface->shutdown(&result);
            wait_forever();
        }
    }

    return EXIT_SUCCESS;
}
コード例 #12
0
int main (int argc, char *argv[])
{
  gchar *prgname;
  GsmInhibitorFlag inhibit_flags = 0;
  gboolean show_help = FALSE;
  gboolean show_version = FALSE;
  gboolean no_launch = FALSE;
  gint i;
  const gchar *app_id = "unknown";
  const gchar *reason = "not specified";

  prgname = g_path_get_basename (argv[0]);
  g_set_prgname (prgname);
  g_free (prgname);

  setlocale (LC_ALL, "");
  bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);

  for (i = 1; i < argc; i++)
    {
      if (strcmp (argv[i], "--help") == 0 ||
          strcmp (argv[i], "-h") == 0)
        show_help = TRUE;
      else if (strcmp (argv[i], "--version") == 0)
        show_version = TRUE;
      else if (strcmp (argv[i], "--inhibit-only") == 0)
        no_launch = TRUE;
      else if (strcmp (argv[i], "--app-id") == 0)
        {
          i++;
          if (i == argc)
            {
              g_print (_("%s requires an argument\n"), argv[i]);
              exit (1);
            }
          app_id = argv[i];
        }
      else if (strcmp (argv[i], "--reason") == 0)
        {
          i++;
          if (i == argc)
            {
              g_print (_("%s requires an argument\n"), argv[i]);
              exit (1);
            }
          reason = argv[i];
        }
      else if (strcmp (argv[i], "--inhibit") == 0)
        {
          i++;
          if (i == argc)
            {
              g_print (_("%s requires an argument\n"), argv[i]);
              exit (1);
            }
          inhibit_flags |= parse_flags (argv[i]);
        }
      else
        break;
    }

  if (show_version)
    {
      version ();
      return 0;
    }

  if (show_help || (i == argc && !no_launch))
    {
      usage ();
      return 0;
    }

  if (inhibit_flags == 0)
    inhibit_flags = GSM_INHIBITOR_FLAG_IDLE;

  if (inhibit (app_id, reason, inhibit_flags) == FALSE)
    return 1;

  if (!no_launch)
    wait_for_child_app (argv + i);
  else
    wait_forever ();

  return 0;
}
コード例 #13
0
ファイル: BKGDBELL.C プロジェクト: Ced2911/umk3
void bell_fall_scan(void)
{
	long a0,a1,a2,a3,a4,a5,a6,a7;
	OBJECT *oa8,*oa0;
	OBJECT *obj=current_proc->pa8;

	if (distance_off_ground(current_proc,current_proc->pa8)<=224)
		return;						// wait to get off screen

	stop_me(current_proc->pa8);
	obj->oxpos.u.intpos=0xb0;		// SCX(600);
	process_sleep(0x50);			// let scroller catch up!

	set_noedge(current_proc->pdata.p_otherguy);		// dont allow otherguy to update position with neew world edges

	obj->oyvel.pos=SCY(0xc0000);
	obj->ograv.pos=0;
	set_x_vel(current_proc->pa8,0);

	/* bfall3 */
	do
	{
		process_sleep(1);
	}
	while(distance_off_ground(current_proc,current_proc->pa8)>SCY(0x10));

	dallprc(PID_BACKG);
	dallprc(PID_SCROLL);
	stop_scrolling();

	a0=worldtlx.pos;
	a1=worldtlx1.pos;
	a2=worldtlx2.pos;
	a3=worldtlx3.pos;
	a4=worldtlx4.pos;
	a5=worldtlx5.pos;
	a6=worldtlx6.pos;
	a7=worldtlx7.pos;

	/* init */
	init_background_module(bell2_module);
	worldtly.u.intpos-=SCY(0x50);
	multi_plane();
	worldtly.u.intpos+=SCY(0x50);

	worldtlx.pos=a0;
	worldtlx1.pos=a1;
	worldtlx2.pos=a2;
	worldtlx3.pos=a3;
	worldtlx4.pos=a4;
	worldtlx5.pos=a5;
	worldtlx6.pos=a6;
	worldtlx7.pos=a7;

	(OBJECT *)a0=baklst8;
	a7=0;
	/* adj8 */
	do
	{
		a1=((OBJECT *)a0)->oypos.u.intpos=((OBJECT *)a0)->oypos.u.intpos+ONE_FLOOR;
		a1+=((OBJECT *)a0)->osize.u.ypos;
		if (a1>=a7)
			a7=a1;				// new lowest point

		(OBJECT *)a0=((OBJECT*)a0)->olink;
	}
	while((OBJECT *)a0!=NULL);

	/* tack on xtra pieces to bottom of floor */
	(long)current_proc->a7=a7;
	(long)current_proc->a6=worldtlx.u.intpos;
	current_proc->a3=0;
	floor_piece();
	broken_floor_a();
	broken_floor_b();
	current_proc->a3^=1;
	floor_piece();

	CREATE(PID_FX,crash_fx)->pa8=(OBJECT *)(current_proc->pdata.p_store7);
	scrolly.pos=SCY(0xc0000);					// dont fall 2 fast

	/* wait_old_offscreen */
	do
	{
		process_sleep(1);
	}
	while(worldtly.u.intpos<SCRBOT);

	current_proc->pa8=(OBJECT*)current_proc->pdata.p_store7;
	clear_shadow_bit(current_proc->pdata.p_otherguy);
	set_inviso(current_proc->pdata.p_otherguy);

	/* get rid of bell tower #1 images */
	f_skew=0;
	delolist(&baklst1);
	delolist(&baklst2);
	delolist(&baklst3);
	delolist(&baklst4);
	delolist(&baklst5);
	delolist(&baklst6);
	delolist(&baklst7);

	/* make another copy of bell2 on list 7 */
	(short)current_proc->a10=worldtly.u.intpos;
	worldtlx7.pos=worldtlx8.pos;
	current_proc->pa8=oa8=baklst8;
	oa0=get_object();
	copy_obj(oa8,oa0);
	baklst7=oa0;
	goto copy81;

	/* copy8 */
	do
	{
		oa0=get_object();
		copy_obj(oa8,oa0);
		((OBJECT *)current_proc->pa9)->olink=oa0;
copy81:
		oa0->oypos.u.intpos+=ONE_FLOOR;
		oa0->olink=NULL;
		(OBJECT *)current_proc->pa9=oa0;
		oa8=oa8->olink;
	}
	while(oa8!=NULL);

	scroll_down_1_floor();
	baklst_down_2_floors(&baklst8);
	scroll_down_1_floor();
	baklst_down_2_floors(&baklst7);

	/* speed up past the guy !! */
	scrolly.pos=SCY(0x100000);				// dont fall to fast
	scroll_down_1_floor();

	/* fix borken pieces !!! */
	fix_broken_pieces(baklst7);
	fix_broken_pieces(baklst8);

	baklst_down_2_floors(&baklst8);
	scroll_down_1_floor();
	baklst_down_2_floors(&baklst7);
	scroll_down_1_floor();

	current_proc->a10=14;
	(short)current_proc->a3=worldtlx.u.intpos;
	/* spike3 */
	do
	{
		oa0=make_a_spike();
		oa0->ozval=0;

		oa0=make_a_spike();
		oa0->ozval=100;

	}
	while(--current_proc->a10>0 );

	process_sleep(5);
	scrolly.pos=0;
	current_proc->pa8=oa8=(OBJECT*)current_proc->pdata.p_store7;

	/* falld3, fall till I meet my maker !!! */
	do
	{
		process_sleep(1);
	}
	while(oa8->oypos.u.intpos<SCY(0xa40) );

	rsnd_stab();
	death_scream;
	find_ani_part2(ANIM_KDOWN);
	do_next_a9_frame(oa8);

	oa8->oyvel.pos=SCY(0xa0000);

	/* falld4 */
	do
	{
		process_sleep(1);
		oa8->oyvel.pos>>=4;
	}
	while(oa8->oyvel.pos>SCY(0x10000) );

	ground_y=oa8->oypos.u.intpos+SCY(0x100);
	create_blood_proc(BLOOD_PIT);

	process_sleep(10);

	death_blow_complete();
	f_no_bonus=0;								// allow bonus routine to do its thing
	stop_a8(oa8);
	wait_forever();
}
コード例 #14
0
ファイル: main.cpp プロジェクト: bju2000/DualBootPatcher
int main(int argc, char *argv[])
{
    enum {
        OPT_NO_LOG_FILE = 1000,
    };

    static struct option long_options[] = {
        { "no-log-file", no_argument, 0, OPT_NO_LOG_FILE },
        { "help",        no_argument, 0, 'h'             },
        { 0, 0, 0, 0 }
    };

    int opt;
    int long_index = 0;
    bool no_log_file = false;

    while ((opt = getopt_long(argc, argv, "h", long_options, &long_index)) != -1) {
        switch (opt) {
        case OPT_NO_LOG_FILE:
            no_log_file = true;
            break;

        case 'h':
            usage(stdout);
            return EXIT_SUCCESS;

        default:
            usage(stderr);
            return EXIT_FAILURE;
        }
    }

    // There should be one other argument
    if (argc - optind != 1) {
        usage(stderr);
        return EXIT_FAILURE;
    }

    umask(0);

    if (!mb::util::mkdir_recursive(MBBOOTUI_BASE_PATH, 0755)) {
        LOGE("%s: Failed to create directory: %s",
             MBBOOTUI_BASE_PATH, strerror(errno));
        return EXIT_FAILURE;
    }

    if (!no_log_file && !redirect_output_to_file(MBBOOTUI_LOG_PATH, 0600)) {
        return EXIT_FAILURE;
    }

    signal(SIGPIPE, SIG_IGN);

    // Set paths
    tw_resource_path = MBBOOTUI_THEME_PATH;
    tw_settings_path = MBBOOTUI_SETTINGS_PATH;
    tw_screenshots_path = MBBOOTUI_SCREENSHOTS_PATH;
    // Disallow custom themes, which could manipulate variables in such as way
    // as to execute malicious code
    tw_theme_zip_path = "";

    if (!detect_device()) {
        return EXIT_FAILURE;
    }

    // Check if device supports the boot UI
    if (!device->twOptions()->supported) {
        LOGW("Boot UI is not supported for the device");
        return EXIT_FAILURE;
    }

    // Load device configuration options
    load_device_config();

    log_startup();

    if (!extract_theme(argv[optind], MBBOOTUI_THEME_PATH,
                       device->twOptions()->theme)) {
        LOGE("Failed to extract theme");
        return EXIT_FAILURE;
    }

    // Connect to daemon
    if (!mbtool_connection.connect()) {
        LOGE("Failed to connect to mbtool");
        return EXIT_FAILURE;
    }
    mbtool_interface = mbtool_connection.interface();

    LOGV("Loading default values...");
    DataManager::SetDefaultValues();

    // Set daemon version
    std::string mbtool_version;
    mbtool_interface->version(&mbtool_version);
    DataManager::SetValue(TW_MBTOOL_VERSION, mbtool_version);

    // Set ROM ID
    std::string rom_id;
    mbtool_interface->get_booted_rom_id(&rom_id);
    DataManager::SetValue(TW_ROM_ID, rom_id);

    LOGV("Loading graphics system...");
    if (gui_init() < 0) {
        LOGE("Failed to load graphics system");
        return EXIT_FAILURE;
    }

    LOGV("Loading resources...");
    gui_loadResources();

    LOGV("Loading user settings...");
    DataManager::ReadSettingsFile();

    LOGV("Loading language...");
    PageManager::LoadLanguage(DataManager::GetStrValue(TW_LANGUAGE));
    GUIConsole::Translate_Now();

    LOGV("Fixing time...");
    TWFunc::Fixup_Time_On_Boot();

    LOGV("Loading main UI...");
    //gui_start();
    gui_startPage("autoboot", 1, 0);

    // Exit action
    std::string exit_action;
    DataManager::GetValue(TW_EXIT_ACTION, exit_action);
    std::vector<std::string> args = mb::util::split(exit_action, ",");

    // Save settings
    DataManager::Flush();

    if (args.size() > 0) {
        if (args[0] == "reboot") {
            std::string reboot_arg;
            if (args.size() > 1) {
                reboot_arg = args[1];
            }
            bool result;
            mbtool_interface->reboot(reboot_arg, &result);
            wait_forever();
        } else if (args[0] == "shutdown") {
            bool result;
            mbtool_interface->shutdown(&result);
            wait_forever();
        }
    }

    return EXIT_SUCCESS;
}
コード例 #15
0
void main(void)
{
/* USER CODE BEGIN (3) */
	uint32 No_Of_MPU_Region = 0;
	uint32 error = 0;
	sciInit();
	sci_printf("TI Hercules Development Kit is running.\r\n", error);
	sci_printf("MPU test is running...\r\n", error);

	/* Initialize memory protection unit.
	* Region configurations are selected using MPU Tab in HALCoGen.
	* MPU is enabled in mpuInit function if "Enable MPU" in GUI is selected */
	_mpuInit_();

	/* This function returns the number of implemented mpu regions. */
	No_Of_MPU_Region = _mpuGetNumberOfRegions_();

	/* Check that device supports 12 Region. */
	if(No_Of_MPU_Region != 12) {
		error |= MPU_ERR_NUMBER_OF_REGIONS;
	}
	/* Select MPU Region 1 */
	_mpuSetRegion_(mpuREGION6);

	/* Check whether MPU Region 6 is selected */
	if(_mpuGetRegion_() != mpuREGION6) {
		/* Region 6 was Not selected */
		error |= MPU_ERR_REGION_SELECTION;
	}
	/* Check the Base address configured for MPU Region 6 */
	else if(_mpuGetRegionBaseAddress_() != SDRAM_BASE_ADDRESS) {
		/*Region 6 Base address wrong */
		error |= MPU_ERR_REGION_BASE_ADDRESS;
	}
	/* Check the Type configured for MPU Region 6 */
	else if(_mpuGetRegionType_() != MPU_STRONGLYORDERED_SHAREABLE) {
		/*Region 6 Type configured wrong */
		error |= MPU_ERR_REGION_TYPE;
	}
	/* Check the Permission configured for MPU Region 6 */
	else if(_mpuGetRegionPermission_() != MPU_PRIV_RW_USER_RW_EXEC) {
		/*Region 6 Permission configured wrong */
		error |= MPU_ERR_REGION_PERMISSION;
	}
	else {
		/* Region 1 Configurations are checked,
		* Matches MPU configuration through HALCoGen GUI */
		asm("	nop");
	}

    if(error != 0)
    {
    	sci_printf("MPU check failed: 0x%X\r\n", error);
    	/* Test Failed */
    	wait_forever();
    }
    else
    {
    	sci_printf("MPU check passed.\r\n");
    	wait_forever();
    }

/* USER CODE END */
}