/* set up the GDB stub serial port baud rate timers  */
void gdbstub_set_baud(unsigned baud)
/* set up the GDB stub serial port baud rate timers  */
void gdbstub_set_baud(unsigned baud)
{
	unsigned value, high, low;
	u8 lcr;
	value = __serial_clock_speed_HZ / 16 / baud;
	high = __serial_clock_speed_HZ / 16 / value;
	low = __serial_clock_speed_HZ / 16 / (value + 1);
	if (low + (high - low) / 2 > baud)
		value++;
	lcr = __UART(LCR);
	__UART(LCR) |= UART_LCR_DLAB;
	mb();
	__UART(DLL) = value & 0xff;
	__UART(DLM) = (value >> 8) & 0xff;
	mb();
	__UART(LCR) = lcr;
	mb();
}