summaryrefslogtreecommitdiffstats
path: root/arch/mips/philips/nino/kgdb.c
blob: 0bb03e86f4b5ddc66c482e62583799349b7fc5b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 *  linux/arch/mips/philips/nino/kgdb.c
 *
 *  Copyright (C) 2001 Steven Hill (sjhill@realitydiluted.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 *  Low level functions for remote debugging on PR31700.
 */
#include <asm/system.h>
#include <asm/philips/pr31700.h>

static int remoteDebugInitialized = 0;

void debugInit(void)
{
/*
 * If low-level debugging (before GDB or console operational) is
 * configured, then we do not need to re-initialize the UART.
 */
#ifndef CONFIG_DEBUG_LL
	earlyInitUartPR31700();
#endif
}

char getDebugChar(void)
{
	char buf;
	unsigned long int2, flags;

	if (!remoteDebugInitialized) {
		debugInit();
		remoteDebugInitialized = 1;
	}

	save_and_cli(flags);

	int2 = IntEnable2;

	IntEnable2 = 0;

	while(!(UartA_Ctrl1 & UART_RX_HOLD_FULL));

	buf = UartA_Data;

	IntEnable2 = int2;

	restore_flags(flags);

	return buf;	
}

int putDebugChar(char c)
{
	int i;
	unsigned long int2;

	if (!remoteDebugInitialized) {
		debugInit();
		remoteDebugInitialized = 1;
	}

	int2 = IntEnable2;

	IntEnable2 &=
		~(INT2_UARTATXINT | INT2_UARTATXOVERRUN | INT2_UARTAEMPTY);

	for (i = 0; !(IntStatus2 & INT2_UARTATXINT) && (i < 10000); i++);

	IntClear2 = INT2_UARTATXINT | INT2_UARTATXOVERRUN | INT2_UARTAEMPTY;

	UartA_Data = c;

	for (i = 0; !(IntStatus2 & INT2_UARTATXINT) && (i < 10000); i++);

	IntClear2 = INT2_UARTATXINT | INT2_UARTATXOVERRUN | INT2_UARTAEMPTY;

	IntEnable2 = int2;

	return 1;
}