/*
 *  board_console_init()
 *
 *  Add the console device and set it to be the primary
 *  console.
 *
 *  Input parameters:
 *     nothing
 *
 *  Return value:
 *     nothing
 */
void
board_console_init(void)
{
#if !CFG_MINIMAL_SIZE
	cfe_set_console(CFE_BUFFER_CONSOLE);
#endif

	/* Initialize SB access */
	sih = si_kattach(SI_OSH);
	ASSERT(sih);

	/* Set this to a default value, since nvram_reset needs to use it in OSL_DELAY */
	board_cfe_cpu_speed_upd(sih);

#if !CFG_SIM
	board_pinmux_init(sih);
	/* Check whether NVRAM reset needs be done */
	if (nvram_reset((void *)sih) > 0)
		restore_defaults = 1;
#endif

	/*
	 * init gpio mode for leds and reset button
	 */
	recovery_button_init();
	leds_gpio_init();

	/* Initialize NVRAM access accordingly. In case of invalid NVRAM, load defaults */
	if (nvram_init((void *)sih) > 0)
		restore_defaults = 1;

#if CFG_SIM
	restore_defaults = 0;
#else /* !CFG_SIM */

	if (!restore_defaults)
		board_clock_init(sih);

	board_power_init(sih);
#endif /* !CFG_SIM */

	board_cpu_init(sih);

	/* Initialize UARTs */
	si_serial_init(sih, board_console_add);

	if (cfe_finddev("uart0"))
		cfe_set_console("uart0");
}
Example #2
0
/*
 *  board_console_init()
 *
 *  Add the console device and set it to be the primary
 *  console.
 *
 *  Input parameters:
 *     nothing
 *
 *  Return value:
 *     nothing
 */
void
board_console_init(void)
{
#if !CFG_MINIMAL_SIZE
	cfe_set_console(CFE_BUFFER_CONSOLE);
#endif

	/* Initialize SB access */
	sih = si_kattach(SI_OSH);
	ASSERT(sih);

	/* Set this to a default value, since nvram_reset needs to use it in OSL_DELAY */
	board_cfe_cpu_speed_upd(sih);

#if !CFG_SIM
	board_pinmux_init(sih);
	/* Check whether NVRAM reset needs be done */
	if (nvram_reset((void *)sih) > 0)
		restore_defaults = 1;
#endif

	/* Initialize NVRAM access accordingly. In case of invalid NVRAM, load defaults */
	if (nvram_init((void *)sih) > 0)
		restore_defaults = 1;

#if CFG_SIM
	restore_defaults = 0;
#else /* !CFG_SIM */

	if (!restore_defaults)
		board_clock_init(sih);

	board_power_init(sih);
#endif /* !CFG_SIM */

	board_cpu_init(sih);

	/* Initialize UARTs */
	si_serial_init(sih, board_console_add);

	if (cfe_finddev("uart0"))
		cfe_set_console("uart0");

	printf("Detect CPU turbo button... ");
	detect_turbo_button();
	if (cpu_turbo_mode && atoi(nvram_safe_get("btn_led_mode")))
		board_clock_init(sih);
}
Example #3
0
int
nvram_init(void *sbh)
{
#ifdef ASUS
#else
	ulong offsets[] = {
		FLASH_BASE + 4 MB - NVRAM_SPACE,
		FLASH_BASE + 3 MB - NVRAM_SPACE,
		FLASH_BASE + 2 MB - NVRAM_SPACE,
		FLASH_BASE + 1 MB - NVRAM_SPACE,
		FLASH_BASE + 4 KB,
		FLASH_BASE + 1 KB,
#ifdef _CFE_
		(ulong) embedded_nvram,
#endif
	};
	int i, ret;

#ifdef vxworks
	/* Initialize private semaphore */
	if ((nvram_lock = semBCreate(SEM_Q_FIFO, SEM_FULL)) == NULL) {
		printf("nvram_init: semBCreate failed\n");
		return ERROR;
	}
#endif

	if (sbh) {
		for (i = 4; i < ARRAYSIZE(offsets); i++) {
			nvram_header = (struct nvram_header *) offsets[i];
			if (nvram_header->magic == NVRAM_MAGIC)
				break;
			nvram_header = NULL;
		}
		/* Temporarily initialize with embedded NVRAM */
		ret = _nvram_init();
		if (ret == 0) {
			/* Restore defaults if button held down */
			if (nvram_reset(sbh))
				return 1;
			_nvram_exit();
		}
	}

	/* Find NVRAM */
	for (i = 0; i < ARRAYSIZE(offsets); i++) {
		nvram_header = (struct nvram_header *) offsets[i];
		if (nvram_header->magic == NVRAM_MAGIC)
			break;
		nvram_header = NULL;
	}

	ret = _nvram_init();
	if (ret == 0) {
		/* Restore defaults if embedded NVRAM used */
		if (nvram_header && i >= 4)
			ret = 1;
	}

	return ret;
#endif
}
Example #4
0
int32_t main(int32_t argc, char ** argv)
{
    int32_t i = 0;

    for(i=0; i<argc; i++)
        DEBUG("argv[%d]:%s\n", i, argv[i]);


    if (argc < 2)
        return usage(OK);

    nvram_mtd_size = mtd_size(NVRAM_MTD_NAME);
    DEBUG("nvram_mtd_size = %u\n", nvram_mtd_size);
    if (nvram_mtd_size <= 0)
        return NG;

    if (nvram_filecache(NVRAM_CACHE_FILE) != OK)
        return NG;

    if (nvram_parse(NULL, NVRAM_CACHE_FILE) != OK)
        return NG;

    if (0 == strcasecmp(argv[1], "commit"))
    {
        return nvram_commit(1);
    }
    else if (0 == strcasecmp(argv[1], "set"))
    {
        if (argc == 5)
            return nvram_set(argv[2], argv[3], argv[4]);
        else
            return usage(NG);
    }
    else if (0 == strcasecmp(argv[1], "get"))
    {
        if (argc < 4)
            return usage(NG);
        else
            nvram_get(argv[2], argv[3]);
    }
    else if (0 == strcasecmp(argv[1], "del"))
    {
        if (argc < 4)
            return usage(NG);
        else
            nvram_del(argv[2], argv[3]);
    }
    else if (0 == strcasecmp(argv[1], "show"))
    {
        if (argc < 3)
            return nvram_show(NULL);
        else
            return nvram_show(argv[2]);
    }
    else if (0 == strcasecmp(argv[1], "clear"))
    {
        return nvram_clear(argv[2]);
    }
    else if (0 == strcasecmp(argv[1], "reset"))
    {
        if (argc < 4)
            return usage(NG);
        else
            return nvram_reset(argv[2], argv[3]);
    }
    else
        return usage(NG);

    return OK;
}