diff options
Diffstat (limited to 'arch/mips/nxp/pnx8550/common/gdb_hook.c')
-rw-r--r-- | arch/mips/nxp/pnx8550/common/gdb_hook.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/arch/mips/nxp/pnx8550/common/gdb_hook.c b/arch/mips/nxp/pnx8550/common/gdb_hook.c new file mode 100644 index 000000000000..ad4624f6d9bc --- /dev/null +++ b/arch/mips/nxp/pnx8550/common/gdb_hook.c | |||
@@ -0,0 +1,109 @@ | |||
1 | /* | ||
2 | * Carsten Langgaard, carstenl@mips.com | ||
3 | * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. | ||
4 | * | ||
5 | * ######################################################################## | ||
6 | * | ||
7 | * This program is free software; you can distribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License (Version 2) as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
14 | * for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
19 | * | ||
20 | * ######################################################################## | ||
21 | * | ||
22 | * This is the interface to the remote debugger stub. | ||
23 | * | ||
24 | */ | ||
25 | #include <linux/types.h> | ||
26 | #include <linux/serial.h> | ||
27 | #include <linux/serialP.h> | ||
28 | #include <linux/serial_reg.h> | ||
29 | #include <linux/serial_ip3106.h> | ||
30 | |||
31 | #include <asm/serial.h> | ||
32 | #include <asm/io.h> | ||
33 | |||
34 | #include <uart.h> | ||
35 | |||
36 | static struct serial_state rs_table[IP3106_NR_PORTS] = { | ||
37 | }; | ||
38 | static struct async_struct kdb_port_info = {0}; | ||
39 | |||
40 | void rs_kgdb_hook(int tty_no) | ||
41 | { | ||
42 | struct serial_state *ser = &rs_table[tty_no]; | ||
43 | |||
44 | kdb_port_info.state = ser; | ||
45 | kdb_port_info.magic = SERIAL_MAGIC; | ||
46 | kdb_port_info.port = tty_no; | ||
47 | kdb_port_info.flags = ser->flags; | ||
48 | |||
49 | /* | ||
50 | * Clear all interrupts | ||
51 | */ | ||
52 | /* Clear all the transmitter FIFO counters (pointer and status) */ | ||
53 | ip3106_lcr(UART_BASE, tty_no) |= IP3106_UART_LCR_TX_RST; | ||
54 | /* Clear all the receiver FIFO counters (pointer and status) */ | ||
55 | ip3106_lcr(UART_BASE, tty_no) |= IP3106_UART_LCR_RX_RST; | ||
56 | /* Clear all interrupts */ | ||
57 | ip3106_iclr(UART_BASE, tty_no) = IP3106_UART_INT_ALLRX | | ||
58 | IP3106_UART_INT_ALLTX; | ||
59 | |||
60 | /* | ||
61 | * Now, initialize the UART | ||
62 | */ | ||
63 | ip3106_lcr(UART_BASE, tty_no) = IP3106_UART_LCR_8BIT; | ||
64 | ip3106_baud(UART_BASE, tty_no) = 5; // 38400 Baud | ||
65 | } | ||
66 | |||
67 | int putDebugChar(char c) | ||
68 | { | ||
69 | /* Wait until FIFO not full */ | ||
70 | while (((ip3106_fifo(UART_BASE, kdb_port_info.port) & IP3106_UART_FIFO_TXFIFO) >> 16) >= 16) | ||
71 | ; | ||
72 | /* Send one char */ | ||
73 | ip3106_fifo(UART_BASE, kdb_port_info.port) = c; | ||
74 | |||
75 | return 1; | ||
76 | } | ||
77 | |||
78 | char getDebugChar(void) | ||
79 | { | ||
80 | char ch; | ||
81 | |||
82 | /* Wait until there is a char in the FIFO */ | ||
83 | while (!((ip3106_fifo(UART_BASE, kdb_port_info.port) & | ||
84 | IP3106_UART_FIFO_RXFIFO) >> 8)) | ||
85 | ; | ||
86 | /* Read one char */ | ||
87 | ch = ip3106_fifo(UART_BASE, kdb_port_info.port) & | ||
88 | IP3106_UART_FIFO_RBRTHR; | ||
89 | /* Advance the RX FIFO read pointer */ | ||
90 | ip3106_lcr(UART_BASE, kdb_port_info.port) |= IP3106_UART_LCR_RX_NEXT; | ||
91 | return (ch); | ||
92 | } | ||
93 | |||
94 | void rs_disable_debug_interrupts(void) | ||
95 | { | ||
96 | ip3106_ien(UART_BASE, kdb_port_info.port) = 0; /* Disable all interrupts */ | ||
97 | } | ||
98 | |||
99 | void rs_enable_debug_interrupts(void) | ||
100 | { | ||
101 | /* Clear all the transmitter FIFO counters (pointer and status) */ | ||
102 | ip3106_lcr(UART_BASE, kdb_port_info.port) |= IP3106_UART_LCR_TX_RST; | ||
103 | /* Clear all the receiver FIFO counters (pointer and status) */ | ||
104 | ip3106_lcr(UART_BASE, kdb_port_info.port) |= IP3106_UART_LCR_RX_RST; | ||
105 | /* Clear all interrupts */ | ||
106 | ip3106_iclr(UART_BASE, kdb_port_info.port) = IP3106_UART_INT_ALLRX | | ||
107 | IP3106_UART_INT_ALLTX; | ||
108 | ip3106_ien(UART_BASE, kdb_port_info.port) = IP3106_UART_INT_ALLRX; /* Enable RX interrupts */ | ||
109 | } | ||