示例#1
0
/**
 * NOTE: don't attempt to quicken by change send rate to 500 ms or less --
 * it's too fast for default 9600 baud rate.
 * For AGPS online, force dumping EPH and ALM.
 */
gboolean agps_dump_aid_data(gboolean agps_online)
{
	log_info("Dump AID data...");

	get_aid_file_names();

	/* avoid garbage */
	uart_flush_output();

	gboolean ret = FALSE;

	struct stat st;
	struct timeval time;
	gettimeofday(&time, NULL);

	aid_args_t config[] = {
		{aid_eph_file, "EPH", UBX_ID_AID_EPH, 104, 32},
		{aid_alm_file, "ALM", UBX_ID_AID_ALM, 40, 32},
		{aid_hui_file, "HUI", UBX_ID_AID_HUI, 72, 1} /* must be last */
	};

	int i;
	int count = sizeof(config)/sizeof(aid_args_t);
	int skip_counter = 0;

	/* AGPS online data does not contain HUI */
	if (agps_online)
		--count;

	for (i=0; i<count; i++) {
		if (agps_online || (stat(config[i].file, &st) != 0) ||
			(st.st_mtim.tv_sec + MIN_DUMP_INTERVAL_S < time.tv_sec)) {
			if (! dump_aid_data(&config[i])) {
				ret = FALSE;
				break;
			}
		} else {
			++skip_counter;
		}
	}

	ret = (i == count);

	if (ret) {
		log_info("Dump AID data result: types=%d", count - skip_counter);
	} else {
		log_info("Dump AID data: failed");
	}

	if (! g_context.uart_conflict)
		uart_flush_output();

	return ret;
}
示例#2
0
文件: th.c 项目: coreboot/chrome-ec
void cts_task(void)
{
	enum cts_rc result;
	int i;

	uart_flush_output();
	for (i = 0; i < CTS_TEST_ID_COUNT; i++) {
		sync();
		result = tests[i].run();
		CPRINTF("\n%s %d\n", tests[i].name, result);
		uart_flush_output();
	}

	CPRINTS("GPIO test suite finished");
	uart_flush_output();
	while (1) {
		watchdog_reload();
		sleep(1);
	}
}
示例#3
0
void panic_puts(const char *outstr)
{
	/* Flush the output buffer */
	uart_flush_output();

	/* Put all characters in the output buffer */
	while (*outstr)
		panic_txchar(NULL, *outstr++);

	/* Flush the transmit FIFO */
	uart_tx_flush();
}
示例#4
0
文件: system.c 项目: thehobn/ec
/**
 * Jump to what we hope is the init address of an image.
 *
 * This function does not return.
 *
 * @param init_addr	Init address of target image
 */
static void jump_to_image(uintptr_t init_addr)
{
	void (*resetvec)(void) = (void(*)(void))init_addr;

	/*
	 * Jumping to any image asserts the signal to the Silego chip that that
	 * EC is not in read-only firmware.  (This is not technically true if
	 * jumping from RO -> RO, but that's not a meaningful use case...).
	 *
	 * Pulse the signal long enough to set the latch in the Silego, then
	 * drop it again so we don't leak power through the pulldown in the
	 * Silego.
	 */
	gpio_set_level(GPIO_ENTERING_RW, 1);
	usleep(MSEC);
	gpio_set_level(GPIO_ENTERING_RW, 0);

#ifdef CONFIG_USB_POWER_DELIVERY
	/*
	 * Notify USB PD module that we are about to sysjump and give it time
	 * to do what it needs.
	 */
	pd_prepare_sysjump();
	usleep(5*MSEC);
#endif

	/* Flush UART output unless the UART hasn't been initialized yet */
	if (uart_init_done())
		uart_flush_output();

	/* Disable interrupts before jump */
	interrupt_disable();

#ifdef CONFIG_DMA
	/* Disable all DMA channels to avoid memory corruption */
	dma_disable_all();
#endif /* CONFIG_DMA */

	/* Fill in preserved data between jumps */
	jdata->reserved0 = 0;
	jdata->magic = JUMP_DATA_MAGIC;
	jdata->version = JUMP_DATA_VERSION;
	jdata->reset_flags = reset_flags;
	jdata->jump_tag_total = 0;  /* Reset tags */
	jdata->struct_size = sizeof(struct jump_data);

	/* Call other hooks; these may add tags */
	hook_notify(HOOK_SYSJUMP);

	/* Jump to the reset vector */
	resetvec();
}
示例#5
0
文件: system.c 项目: longsleep/ec
/**
 * Jump to what we hope is the init address of an image.
 *
 * This function does not return.
 *
 * @param init_addr	Init address of target image
 */
static void jump_to_image(uintptr_t init_addr)
{
	void (*resetvec)(void) = (void(*)(void))init_addr;

	/*
	 * Jumping to any image asserts the signal to the Silego chip that that
	 * EC is not in read-only firmware.  (This is not technically true if
	 * jumping from RO -> RO, but that's not a meaningful use case...).
	 *
	 * Pulse the signal long enough to set the latch in the Silego, then
	 * drop it again so we don't leak power through the pulldown in the
	 * Silego.
	 */
	gpio_set_level(GPIO_ENTERING_RW, 1);
	usleep(MSEC);
	gpio_set_level(GPIO_ENTERING_RW, 0);

#ifdef CONFIG_USB_POWER_DELIVERY
	/*
	 * On sysjump, we are most definitely going to drop pings (if any)
	 * and lose all of our PD state. Instead of trying to remember all
	 * the states and deal with on-going transmission, let's send soft
	 * reset here so that the communication starts over without dropping
	 * power.
	 */
	pd_soft_reset();
	usleep(5*MSEC);
#endif

	/* Flush UART output unless the UART hasn't been initialized yet */
	if (uart_init_done())
		uart_flush_output();

	/* Disable interrupts before jump */
	interrupt_disable();

	/* Fill in preserved data between jumps */
	jdata->reserved0 = 0;
	jdata->magic = JUMP_DATA_MAGIC;
	jdata->version = JUMP_DATA_VERSION;
	jdata->reset_flags = reset_flags;
	jdata->jump_tag_total = 0;  /* Reset tags */
	jdata->struct_size = sizeof(struct jump_data);

	/* Call other hooks; these may add tags */
	hook_notify(HOOK_SYSJUMP);

	/* Jump to the reset vector */
	resetvec();
}
示例#6
0
void panic_printf(const char *format, ...)
{
	va_list args;

	/* Flush the output buffer */
	uart_flush_output();

	va_start(args, format);
	vfnprintf(panic_txchar, NULL, format, args);
	va_end(args);

	/* Flush the transmit FIFO */
	uart_tx_flush();
}
示例#7
0
文件: uart.c 项目: dss91/omgps
/**
 * baud_rate: only support [1,2,4,8] * 4800
 * called by polling thread!
 */
gboolean uart_init()
{
	log_info("UART init: message rate=%d ms, baud rate=%d...", SEND_RATE, BAUD_RATE);
	show_status("Initializing GPS...");

	/* open UART */
	if (uart_open((U4)BAUD_RATE, TRUE) <= 0) {
		log_error("Open UART failed");
		return FALSE;
	}

	ubx_init(gps_dev_fd);

	if (! ubx_cfg_rate((U2)SEND_RATE, TRUE))
		return FALSE;

	if (! ubx_cfg_prt(0x01, 0x01, 0x01, BAUD_RATE, TRUE))
		return FALSE;

	/* Disable NMEA to avoid flushing UBX binary output */
	if (! ubx_cfg_msg_nmea_ubx(0x0, TRUE, TRUE))
		return FALSE;

	if (! ubx_cfg_msg_nmea_std(0x0, TRUE, TRUE))
		return FALSE;

	if (! ubx_cfg_sbas(TRUE, TRUE))
		return FALSE;

	show_status("Set initial AID data...");

	/* no matter success or failure */
	set_initial_aid_data();

	uart_flush_output();

	show_status("GPS was initialized.");

	//ubx_mon_ver_poll(g_ubx_receiver_versions, sizeof(g_ubx_receiver_versions));
	//show_status(g_ubx_receiver_versions);

	return TRUE;
}
示例#8
0
文件: uart.c 项目: dss91/omgps
/*
 * If the read size < expected length, retry even if EOF
 */
gboolean inline read_fixed_len(U1 *buf, int expected_len)
{
	int len = 0, count;

	while (TRUE) {
		count = read_with_timeout(&buf[len], expected_len);
		if (count == expected_len) {
			return TRUE;
		} else if (count <= 0) {
			uart_flush_output();
			return FALSE;
		} else {
			len += count;
			expected_len -= count;
			if (expected_len == 0)
				return TRUE;
		}
	}
}
示例#9
0
void board_hibernate(void)
{
	CPRINTS("Triggering PMIC shutdown.");
	uart_flush_output();

	/* Trigger PMIC shutdown. */
	if (i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x49, 0x01)) {
		/*
		 * If we can't tell the PMIC to shutdown, instead reset
		 * and don't start the AP. Hopefully we'll be able to
		 * communicate with the PMIC next time.
		 */
		CPRINTS("PMIC i2c failed.");
		system_reset(SYSTEM_RESET_LEAVE_AP_OFF);
	}

	/* Await shutdown. */
	while (1)
		;
}
示例#10
0
/**
 * Jump to what we hope is the init address of an image.
 *
 * This function does not return.
 *
 * @param init_addr	Init address of target image
 */
static void jump_to_image(uintptr_t init_addr)
{
	void (*resetvec)(void) = (void(*)(void))init_addr;

	/*
	 * Jumping to any image asserts the signal to the Silego chip that that
	 * EC is not in read-only firmware.  (This is not technically true if
	 * jumping from RO -> RO, but that's not a meaningful use case...).
	 *
	 * Pulse the signal long enough to set the latch in the Silego, then
	 * drop it again so we don't leak power through the pulldown in the
	 * Silego.
	 */
	gpio_set_level(GPIO_ENTERING_RW, 1);
	usleep(MSEC);
	gpio_set_level(GPIO_ENTERING_RW, 0);

	/* Flush UART output unless the UART hasn't been initialized yet */
	if (uart_init_done())
		uart_flush_output();

	/* Disable interrupts before jump */
	interrupt_disable();

	/* Fill in preserved data between jumps */
	jdata->reserved0 = 0;
	jdata->magic = JUMP_DATA_MAGIC;
	jdata->version = JUMP_DATA_VERSION;
	jdata->reset_flags = reset_flags;
	jdata->jump_tag_total = 0;  /* Reset tags */
	jdata->struct_size = sizeof(struct jump_data);

	/* Call other hooks; these may add tags */
	hook_notify(HOOK_SYSJUMP);

	/* Jump to the reset vector */
	resetvec();
}