Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
1
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
2f2a213
Documentation
arch
alpha
arm
avr32
blackfin
cris
frv
h8300
ia64
m32r
m68k
m68knommu
mips
mn10300
boot
configs
include
kernel
Makefile
asm-offsets.c
entry.S
fpu-low.S
fpu.c
gdb-cache.S
gdb-io-serial-low.S
gdb-io-serial.c
gdb-io-ttysm-low.S
gdb-io-ttysm.c
gdb-low.S
gdb-stub.c
head.S
init_task.c
internal.h
io.c
irq.c
kernel_execve.S
kprobes.c
kthread.S
mn10300-debug.c
mn10300-serial-low.S
mn10300-serial.c
mn10300-serial.h
mn10300-watchdog-low.S
mn10300-watchdog.c
mn10300_ksyms.c
module.c
process.c
profile-low.S
profile.c
ptrace.c
rtc.c
setup.c
sigframe.h
signal.c
switch_to.S
sys_mn10300.c
time.c
traps.c
vmlinux.lds.S
lib
mm
oprofile
proc-mn103e010
unit-asb2303
unit-asb2305
Kconfig
Kconfig.debug
Makefile
parisc
powerpc
s390
sh
sparc
um
x86
xtensa
.gitignore
Kconfig
block
crypto
drivers
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
usr
virt
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
MAINTAINERS
Makefile
README
REPORTING-BUGS
Breadcrumbs
linux
/
arch
/
mn10300
/
kernel
/
gdb-io-serial.c
Copy path
Blame
Blame
Latest commit
History
History
157 lines (134 loc) · 3.32 KB
Breadcrumbs
linux
/
arch
/
mn10300
/
kernel
/
gdb-io-serial.c
Top
File metadata and controls
Code
Blame
157 lines (134 loc) · 3.32 KB
Raw
/* 16550 serial driver for gdbstub I/O * * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public Licence * as published by the Free Software Foundation; either version * 2 of the Licence, or (at your option) any later version. */ #include <linux/string.h> #include <linux/kernel.h> #include <linux/signal.h> #include <linux/sched.h> #include <linux/mm.h> #include <linux/console.h> #include <linux/init.h> #include <linux/nmi.h> #include <asm/pgtable.h> #include <asm/system.h> #include <asm/gdb-stub.h> #include <asm/exceptions.h> #include <asm/serial-regs.h> #include <unit/serial.h> /* * initialise the GDB stub */ void gdbstub_io_init(void) { u16 tmp; /* set up the serial port */ GDBPORT_SERIAL_LCR = UART_LCR_WLEN8; /* 1N8 */ GDBPORT_SERIAL_FCR = (UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); FLOWCTL_CLEAR(DTR); FLOWCTL_SET(RTS); gdbstub_io_set_baud(115200); /* we want to get serial receive interrupts */ XIRQxICR(GDBPORT_SERIAL_IRQ) = 0; tmp = XIRQxICR(GDBPORT_SERIAL_IRQ); IVAR0 = EXCEP_IRQ_LEVEL0; set_intr_stub(EXCEP_IRQ_LEVEL0, gdbstub_io_rx_handler); XIRQxICR(GDBPORT_SERIAL_IRQ) &= ~GxICR_REQUEST; XIRQxICR(GDBPORT_SERIAL_IRQ) = GxICR_ENABLE | GxICR_LEVEL_0; tmp = XIRQxICR(GDBPORT_SERIAL_IRQ); GDBPORT_SERIAL_IER = UART_IER_RDI | UART_IER_RLSI; /* permit level 0 IRQs to take place */ asm volatile( " and %0,epsw \n" " or %1,epsw \n" : : "i"(~EPSW_IM), "i"(EPSW_IE | EPSW_IM_1) ); } /* * set up the GDB stub serial port baud rate timers */ void gdbstub_io_set_baud(unsigned baud) { unsigned value; u8 lcr; value = 18432000 / 16 / baud; lcr = GDBPORT_SERIAL_LCR; GDBPORT_SERIAL_LCR |= UART_LCR_DLAB; GDBPORT_SERIAL_DLL = value & 0xff; GDBPORT_SERIAL_DLM = (value >> 8) & 0xff; GDBPORT_SERIAL_LCR = lcr; } /* * wait for a character to come from the debugger */ int gdbstub_io_rx_char(unsigned char *_ch, int nonblock) { unsigned ix; u8 ch, st; *_ch = 0xff; if (gdbstub_rx_unget) { *_ch = gdbstub_rx_unget; gdbstub_rx_unget = 0; return 0; } try_again: /* pull chars out of the buffer */ ix = gdbstub_rx_outp; barrier(); if (ix == gdbstub_rx_inp) { if (nonblock) return -EAGAIN; #ifdef CONFIG_MN10300_WD_TIMER watchdog_alert_counter = 0; #endif /* CONFIG_MN10300_WD_TIMER */ goto try_again; } ch = gdbstub_rx_buffer[ix++]; st = gdbstub_rx_buffer[ix++]; barrier(); gdbstub_rx_outp = ix & 0x00000fff; if (st & UART_LSR_BI) { gdbstub_proto("### GDB Rx Break Detected ###\n"); return -EINTR; } else if (st & (UART_LSR_FE | UART_LSR_OE | UART_LSR_PE)) { gdbstub_proto("### GDB Rx Error (st=%02x) ###\n", st); return -EIO; } else { gdbstub_proto("### GDB Rx %02x (st=%02x) ###\n", ch, st); *_ch = ch & 0x7f; return 0; } } /* * send a character to the debugger */ void gdbstub_io_tx_char(unsigned char ch) { FLOWCTL_SET(DTR); LSR_WAIT_FOR(THRE); /* FLOWCTL_WAIT_FOR(CTS); */ if (ch == 0x0a) { GDBPORT_SERIAL_TX = 0x0d; LSR_WAIT_FOR(THRE); /* FLOWCTL_WAIT_FOR(CTS); */ } GDBPORT_SERIAL_TX = ch; FLOWCTL_CLEAR(DTR); } /* * send a character to the debugger */ void gdbstub_io_tx_flush(void) { LSR_WAIT_FOR(TEMT); LSR_WAIT_FOR(THRE); FLOWCTL_CLEAR(DTR); }
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
You can’t perform that action at this time.