Initial support for KGDB on the sh3.

This commit is contained in:
uch 2002-03-02 22:26:25 +00:00
parent 65af267aeb
commit 6042c0a3fc
22 changed files with 482 additions and 306 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.17 2002/02/28 16:52:46 uch Exp $
# $NetBSD: GENERIC,v 1.18 2002/03/02 22:26:25 uch Exp $
#
# GENERIC machine description file
#
@ -68,6 +68,8 @@ options HZ=100 # clock interrupt generates every 1/HZ sec
#options DIAGNOSTIC # cheap kernel consistency checks
#options DEBUG # expensive debugging checks/support
#options DDB # in-kernel debugger
#options KGDB # remote debugger
#options "KGDB_DEVNAME=\"scif\"",KGDB_DEVRATE=57600
#makeoptions DEBUG="-g" # compile full symbol table
#options SYSCALL_DEBUG
#options UVMHIST
@ -115,6 +117,7 @@ mainbus0 at root
shb* at mainbus?
# Serial Devices
#options SCIFCONSOLE
options SCIFCN_SPEED=57600
scif0 at shb? port 0xffe80000 irq 12

View File

@ -1,53 +1,79 @@
/* $NetBSD: shl.x,v 1.6 2002/03/02 22:26:25 uch Exp $ */
OUTPUT_FORMAT("elf32-shl-unx")
OUTPUT_ARCH(sh)
ENTRY(start)
MEMORY
{
ram : o = 0x8C010000, l = 16M
ram : o = 0x8c001000, l = 16M
}
SECTIONS
{
.text :
{
ftext = . ;
*(.text)
*(.rodata)
*(.strings)
etext = . ;
_etext = . ; /* XXX */
} > ram
.tors :
{
__ctors = . ;
*(.ctors)
__ctors_end = . ;
__dtors = . ;
*(.dtors)
__dtors_end = . ;
} > ram
etext = . ;
PROVIDE (etext = .);
. = ALIGN(8);
.data :
{
fdata = . ;
PROVIDE (fdata = .);
*(.data)
edata = . ;
_edata = . ; /* XXX */
} > ram
CONSTRUCTORS
} > ram
edata = . ;
PROVIDE (edata = .);
. = ALIGN(8);
.bss :
{
bss_start = . ;
fbss = . ;
PROVIDE (fbss = .);
*(.bss)
*(COMMON)
end = . ;
_end = . ; /* XXX */
} > ram
.stack :
{
stack = . ;
*(.stack)
} > ram
.stab 0 (NOLOAD) :
{
*(.stab)
}
.stabstr 0 (NOLOAD) :
{
*(.stabstr)
}
} > ram
. = ALIGN(4);
end = . ;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging section are relative to the beginning
of the section so we begin .debug at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* These must appear regardless of . */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.11 2002/02/28 16:54:28 uch Exp $ */
/* $NetBSD: machdep.c,v 1.12 2002/03/02 22:26:25 uch Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -79,6 +79,7 @@
#include "opt_kgdb.h"
#include "opt_syscall_debug.h"
#include "opt_memsize.h"
#include "scif.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -103,6 +104,7 @@
#ifdef KGDB
#include <sys/kgdb.h>
#include <sh3/dev/scifvar.h>
#endif
#ifdef DDB
@ -413,13 +415,18 @@ dreamcast_startup()
(caddr_t)iomem_ex_storage, sizeof(iomem_ex_storage),
EX_NOCOALESCE|EX_NOWAIT);
#if 1
consinit(); /* XXX SHOULD NOT BE DONE HERE */
#endif
consinit();
splraise(-1);
_cpu_exception_resume(0); /* SR.BL = 0 */
#if defined(KGDB) && NSCIF > 0
if (scif_kgdb_init() == 0) {
kgdb_debug_init = 1;
kgdb_connect(1);
}
#endif /* KGDB && NSCIF > 0 */
avail_end = sh3_trunc_page(IOM_RAM_END + 1);
printf("initSH3\r\n");

View File

@ -1,6 +1,6 @@
# $NetBSD: HP620LX,v 1.8 2002/02/17 20:59:36 uch Exp $
# $NetBSD: HP620LX,v 1.9 2002/03/02 22:26:25 uch Exp $
#
# HP620LX
# HP HP620LX
#
include "arch/hpcsh/conf/std.hpcsh"
@ -10,6 +10,9 @@ maxusers 32 # estimated number of users
options SH3
options PCLOCK=18432000 # 18MHz
#options KGDB # in-kernel debugger
#options "KGDB_DEVNAME=\"scif\"",KGDB_DEVRATE=19200
#makeoptions DEBUG="-g" # compile full symbol table
options DDB # in-kernel debugger
options DIAGNOSTIC # extra kernel debugging checks
options DEBUG # extra kernel debugging support

View File

@ -1,4 +1,4 @@
# $NetBSD: HPW650PA,v 1.3 2002/02/17 20:59:36 uch Exp $
# $NetBSD: HPW650PA,v 1.4 2002/03/02 22:26:25 uch Exp $
#
# HITACHI PERSONA HPW650PA
#
@ -11,15 +11,18 @@ options KLOADER_KERNEL_PATH="\"/netbsd\""
options KLOADER_DEBUG
options SH4
options PCLOCK=32000000 # 32MHz
options INTERRUPT_MONITOR
options HPC_DEBUG_LCD
options DDB # in-kernel debugger
#options KGDB # in-kernel debugger
#options "KGDB_DEVNAME=\"hd64465uart\"",KGDB_DEVRATE=19200
#makeoptions DEBUG="-g" # compile full symbol table
options DIAGNOSTIC # extra kernel debugging checks
options DEBUG # extra kernel debugging support
options KTRACE # system call tracing support
options MSGBUFSIZE=65534
options PIPE_SOCKETPAIR # smaller, but slower pipe(2)

View File

@ -1,6 +1,6 @@
# $NetBSD: JORNADA690,v 1.15 2002/02/17 20:59:36 uch Exp $
# $NetBSD: JORNADA690,v 1.16 2002/03/02 22:26:25 uch Exp $
#
# JORNADA690 uch's Jornada 690
# HP Jornada680/690
#
include "arch/hpcsh/conf/std.hpcsh"
@ -11,6 +11,9 @@ options SH3
options PCLOCK=22000000 # 22MHz
options DDB # in-kernel debugger
#options KGDB # in-kernel debugger
#options "KGDB_DEVNAME=\"scif\"",KGDB_DEVRATE=19200
#makeoptions DEBUG="-g" # compile full symbol table
options DIAGNOSTIC # extra kernel debugging checks
options DEBUG # extra kernel debugging support
options KTRACE # system call tracing support
@ -71,24 +74,20 @@ options WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes
mainbus0 at root
shb* at mainbus?
# Workstation Console attachments
bivideo0 at mainbus0
hpcfb* at bivideo0
wsdisplay* at hpcfb?
pfckbd* at mainbus?
hpckbd* at pfckbd?
wskbd* at hpckbd? mux 1
# Serial Devices
# don't need to define SCICONSOLE. you can select from bootloader.
options SCIFCN_SPEED=19200
scif0 at shb? port 0xa4000008 irq 12
hd64461if* at shb? irq 4
hd64461video* at hd64461if?
hd64461pcmcia* at hd64461if?
com* at hd64461if?
# Workstation Console attachments
hpcfb* at hd64461video?
wsdisplay* at hpcfb?
pfckbd* at mainbus?
hpckbd* at pfckbd?
wskbd* at hpckbd? mux 1
# PCMCIA bus support
pcmcia0 at hd64461pcmcia? controller 0 socket ? # I/O card, memory card
@ -97,7 +96,7 @@ pcmcia1 at hd64461pcmcia? controller 1 socket ? # memory card only
# PCMCIA network interfaces
ne* at pcmcia0 function ? # NE2000-compatible Ethernet
ep* at pcmcia0 function ? # 3Com 3c589 and 3c562 Ethernet
mbe* at pcmcia0 function ? # MB8696x based Ethernet
#mbe* at pcmcia0 function ? # MB8696x based Ethernet
#wi* at pcmcia0 function ? # Lucent WaveLan IEEE (802.11)
#mhzc* at pcmcia0 function ? # Megahertz Ethernet/Modem combo cards
#com* at mhzc?
@ -124,10 +123,6 @@ wd* at wdc0 channel ? drive ? flags 0x0000
# SCSI devices
#sd* at scsibus? target ? lun ? # SCSI disk drives
# Network Interfaces
# Pseudo-Devices
pseudo-device biconsdev 1 # build-in console device
# network pseudo-devices
pseudo-device bpfilter 8 # Berkeley packet filter

View File

@ -1,4 +1,4 @@
# $NetBSD: files.hpcsh,v 1.21 2002/02/24 18:19:43 uch Exp $
# $NetBSD: files.hpcsh,v 1.22 2002/03/02 22:26:25 uch Exp $
#
maxpartitions 8
@ -85,7 +85,7 @@ attach hd64461pcmcia at hd64461if
file arch/hpcsh/dev/hd64461/hd64461pcmcia.c hd64461pcmcia
attach com at hd64461if with hd64461uart
file arch/hpcsh/dev/hd64461/hd64461uart.c hd64461uart
file arch/hpcsh/dev/hd64461/hd64461uart.c hd64461uart needs-flag
device hd64461video: hpcfbif
attach hd64461video at hd64461if
@ -101,7 +101,7 @@ attach hd64465if at shb
file arch/hpcsh/dev/hd64465/hd64465.c hd64465if needs-flag
attach com at hd64465if with hd64465uart
file arch/hpcsh/dev/hd64465/hd64465uart.c hd64465uart
file arch/hpcsh/dev/hd64465/hd64465uart.c hd64465uart needs-flag
device hd64465pcmcia: pcmciabus
attach hd64465pcmcia at hd64465if

View File

@ -1,4 +1,4 @@
/* $NetBSD: shl-elf.x,v 1.4 2002/02/24 18:19:44 uch Exp $ */
/* $NetBSD: shl-elf.x,v 1.5 2002/03/02 22:26:26 uch Exp $ */
OUTPUT_FORMAT("elf32-shl-unx")
OUTPUT_ARCH(sh)
@ -44,5 +44,36 @@ SECTIONS
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging section are relative to the beginning
of the section so we begin .debug at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* These must appear regardless of . */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: hd64461uart.c,v 1.7 2002/02/11 17:21:48 uch Exp $ */
/* $NetBSD: hd64461uart.c,v 1.8 2002/03/02 22:26:26 uch Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -40,6 +40,7 @@
#include <sys/reboot.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/kgdb.h>
#include <sys/termios.h>
#include <dev/cons.h>
@ -75,8 +76,8 @@ struct hd64461uart_softc {
/* boot console */
cdev_decl(com);
void comcnprobe(struct consdev *);
void comcninit(struct consdev *);
void hd64461uartcnprobe(struct consdev *);
void hd64461uartcninit(struct consdev *);
STATIC int hd64461uart_match(struct device *, struct cfdata *, void *);
STATIC void hd64461uart_attach(struct device *, struct device *, void *);
@ -97,7 +98,7 @@ STATIC void hd64461uart_write_1(void *, bus_space_handle_t, bus_size_t,
#endif
void
comcnprobe(struct consdev *cp)
hd64461uartcnprobe(struct consdev *cp)
{
int maj;
@ -112,25 +113,37 @@ comcnprobe(struct consdev *cp)
}
void
comcninit(struct consdev *cp)
hd64461uartcninit(struct consdev *cp)
{
hd64461uart_init();
#ifdef KGDB
if (strcmp(kgdb_devname, "hd64461uart") == 0) {
if (com_kgdb_attach(hd64461uart_chip.io_tag, 0x0, COMCN_SPEED,
COM_FREQ, CONMODE) == 0) {
return;
}
}
#endif /* KGDB */
comcnattach(hd64461uart_chip.io_tag, 0x0, COMCN_SPEED, COM_FREQ,
CONMODE);
hd64461uart_chip.console = 1;
}
#ifdef KGDB
int
hd64461uart_kgdb_init()
{
if (strcmp(kgdb_devname, "hd64461uart") != 0)
return (1);
hd64461uart_init();
if (com_kgdb_attach(hd64461uart_chip.io_tag, 0x0, kgdb_rate,
COM_FREQ, CONMODE) != 0) {
printf("%s: KGDB console open failed.\n", __FUNCTION__);
return (1);
}
return (0);
}
#endif /* KGDB */
int
hd64461uart_match(struct device *parent, struct cfdata *cf, void *aux)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: hd64461uartvar.h,v 1.3 2002/02/11 17:21:48 uch Exp $ */
/* $NetBSD: hd64461uartvar.h,v 1.4 2002/03/02 22:26:26 uch Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -36,6 +36,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOCORE
int hd64461uart_kgdb_init(void);
#endif
#define HD64461COM_TX_BUSY() \
while ((*(volatile u_int8_t *)HD64461_ULSR_REG8 & LSR_TXRDY) == 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: hd64465uart.c,v 1.1 2002/02/11 17:27:16 uch Exp $ */
/* $NetBSD: hd64465uart.c,v 1.2 2002/03/02 22:26:26 uch Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -40,6 +40,7 @@
#include <sys/reboot.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/kgdb.h>
#include <sys/termios.h>
#include <dev/cons.h>
@ -73,8 +74,8 @@ struct hd64465uart_softc {
/* boot console */
cdev_decl(com);
void comcnprobe(struct consdev *);
void comcninit(struct consdev *);
void hd64465uartcnprobe(struct consdev *);
void hd64465uartcninit(struct consdev *);
STATIC int hd64465uart_match(struct device *, struct cfdata *, void *);
STATIC void hd64465uart_attach(struct device *, struct device *, void *);
@ -95,7 +96,7 @@ STATIC void hd64465uart_write_1(void *, bus_space_handle_t, bus_size_t,
#endif
void
comcnprobe(struct consdev *cp)
hd64465uartcnprobe(struct consdev *cp)
{
int maj;
@ -110,7 +111,7 @@ comcnprobe(struct consdev *cp)
}
void
comcninit(struct consdev *cp)
hd64465uartcninit(struct consdev *cp)
{
hd64465uart_init();
@ -121,6 +122,26 @@ comcninit(struct consdev *cp)
hd64465uart_chip.console = 1;
}
#ifdef KGDB
int
hd64465uart_kgdb_init()
{
if (strcmp(kgdb_devname, "hd64465uart") != 0)
return (1);
hd64465uart_init();
if (com_kgdb_attach(hd64465uart_chip.io_tag, 0x0, kgdb_rate,
COM_FREQ, CONMODE) != 0) {
printf("%s: KGDB console open failed.\n", __FUNCTION__);
return (1);
}
return (0);
}
#endif /* KGDB */
int
hd64465uart_match(struct device *parent, struct cfdata *cf, void *aux)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: hd64465uartvar.h,v 1.1 2002/02/11 17:27:16 uch Exp $ */
/* $NetBSD: hd64465uartvar.h,v 1.2 2002/03/02 22:26:26 uch Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -36,6 +36,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOCORE
int hd64465uart_kgdb_init(void);
#endif
#define HD64465COM_TX_BUSY() \
while ((VOLATILE_REF8(HD64465_ULSR_REG8) & LSR_TXRDY) == 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: console.c,v 1.7 2002/02/11 17:32:35 uch Exp $ */
/* $NetBSD: console.c,v 1.8 2002/03/02 22:26:26 uch Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -37,14 +37,12 @@
*/
#include "opt_kgdb.h"
#include "biconsdev.h"
#include "hpcfb.h"
#include "sci.h"
#include "scif.h"
#include "com.h"
#include "hd64461uart.h"
#include "hd64465uart.h"
#include "hd64461video.h"
#include "wskbd.h"
#include "pfckbd.h"
@ -55,35 +53,29 @@
#include <machine/bootinfo.h>
#if !defined(NBICONSDEV) || !defined(NHPCFB) || !defined(NPFCKBD) || \
!defined(NHD64461VIDEO) || !defined(NSCI) || !defined(NSCIF) || \
!defined(NCOM)
#error
#endif
#if NBICONSDEV > 0
#include <dev/hpc/biconsvar.h>
#include <dev/hpc/bicons.h>
#endif
#if NHPCFB > 0
#include <dev/wscons/wsdisplayvar.h>
#include <dev/rasops/rasops.h>
#include <dev/hpc/bicons.h>
#include <dev/hpc/biconsvar.h>
#include <dev/hpc/hpcfbvar.h>
#endif
#if NPFCKBD > 0
#include <sh3/dev/scifvar.h>
#include <hpcsh/dev/pfckbdvar.h>
#endif
#include <hpcsh/dev/hd64461/hd64461uartvar.h>
#include <hpcsh/dev/hd64465/hd64465uartvar.h>
/* serial console */
#define scicnpollc nullcnpollc
cons_decl(sci);
/* Serial console */
#define scifcnpollc nullcnpollc
cons_decl(scif);
cons_decl(com);
#define hd64461uartcnputc comcnputc
#define hd64461uartcngetc comcngetc
#define hd64461uartcnpollc comcnpollc
cons_decl(hd64461uart);
#define hd64465uartcnputc comcnputc
#define hd64465uartcngetc comcngetc
#define hd64465uartcnpollc comcnpollc
cons_decl(hd64465uart);
/* builtin video console */
/* Builtin video console */
#if NBICONSDEV > 0
#define biconscnpollc nullcnpollc
cons_decl(bicons);
@ -95,7 +87,7 @@ cons_decl(hd64461video_);
#if NWSKBD > 0
#include <dev/wscons/wskbdvar.h>
#define hd64461video_cngetc wskbd_cngetc
#else
#else /* NWSKBD > 0 */
int
hd64461video_cngetc(dev_t dev)
{
@ -104,10 +96,10 @@ hd64461video_cngetc(dev_t dev)
;
/* NOTREACHED */
}
#endif
#endif /* NWSKBD > 0 */
#define hd64461video_cnputc wsdisplay_cnputc
#define hd64461video_cnpollc nullcnpollc
#endif
#endif /* NHD64461VIDEO > 0 */
struct consdev constab[] = {
#if NBICONSDEV > 0
@ -116,25 +108,19 @@ struct consdev constab[] = {
#if NHD64461VIDEO > 0
cons_init(hd64461video_),
#endif
#if NSCI > 0
cons_init(sci),
#endif
#if NSCIF > 0
cons_init(scif),
#endif
#if NCOM > 0
cons_init(com),
#if NHD64461UART > 0
cons_init(hd64461uart),
#endif
#if NHD64465UART > 0
cons_init(hd64465uart),
#endif
{ 0 } /* terminator */
};
#define CN_ENABLE(x) set_console(x ## cnputc, x ## cnprobe)
#ifdef KGDB
#ifndef KGDB_DEVNAME
#define KGDB_DEVNAME "nodev"
#endif
const char kgdb_devname[] = KGDB_DEVNAME;
#endif
static int initialized;
static int attach_kbd __attribute__((__unused__)) = 1;
static void set_console(void (*)(dev_t, int), void (*)(struct consdev *));
@ -163,11 +149,6 @@ consinit()
#if NHD64461VIDEO > 0
CN_ENABLE(hd64461video_);
attach_kbd = 1;
#endif
break;
case BI_CNUSE_SCI:
#if NSCI > 0
CN_ENABLE(sci);
#endif
break;
case BI_CNUSE_SCIF:
@ -175,11 +156,14 @@ consinit()
CN_ENABLE(scif);
#endif
break;
case BI_CNUSE_HD64465COM:
/* FALLTHROUGH */
case BI_CNUSE_HD64461COM:
#if NCOM > 0
CN_ENABLE(com);
#if NHD64461UART > 0
CN_ENABLE(hd64461uart);
#endif
break;
case BI_CNUSE_HD64465COM:
#if NHD64465UART > 0
CN_ENABLE(hd64465uart);
#endif
break;
}
@ -203,6 +187,18 @@ consinit()
if (cn_tab->cn_putc == biconscnputc)
hpcfb_cnattach(0);
#endif
#ifdef KGDB
#if NSCIF > 0
scif_kgdb_init();
#endif
#if NHD64461UART > 0
hd64461uart_kgdb_init();
#endif
#if NHD64465UART > 0
hd64465uart_kgdb_init();
#endif
#endif /* KGDB */
}
static void

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.28 2002/02/28 18:17:29 uch Exp $ */
/* $NetBSD: machdep.c,v 1.29 2002/03/02 22:26:26 uch Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -197,7 +197,13 @@ machine_startup(int argc, char *argv[], struct bootinfo *bi)
platid.dw.dw1 = bootinfo->platid_machine;
}
/* ICU initiailze */
/* CPU initialize */
if (platid_match(&platid, &platid_mask_CPU_SH_3))
sh_cpu_init(CPU_ARCH_SH3, CPU_PRODUCT_7709A);
else if (platid_match(&platid, &platid_mask_CPU_SH_4))
sh_cpu_init(CPU_ARCH_SH4, CPU_PRODUCT_7750);
/* ICU initiailze. (now we can use cpu_arch and cpu_product) */
switch (cpu_product) {
case CPU_PRODUCT_7709A:
_reg_write_2(SH7709_IPRC, 0);
@ -218,12 +224,6 @@ machine_startup(int argc, char *argv[], struct bootinfo *bi)
hd64465_intr_disable();
#endif
/* CPU initialize */
if (platid_match(&platid, &platid_mask_CPU_SH_3))
sh_cpu_init(CPU_ARCH_SH3, CPU_PRODUCT_7709A);
else if (platid_match(&platid, &platid_mask_CPU_SH_4))
sh_cpu_init(CPU_ARCH_SH4, CPU_PRODUCT_7750);
/* Start to determine heap area */
kernend = (vaddr_t)sh3_round_page(end + symbolsize);
@ -346,8 +346,12 @@ machine_startup(int argc, char *argv[], struct bootinfo *bi)
#endif /* DDB */
#ifdef KGDB
if (boothowto & RB_KDB) {
kgdb_debug_init = 1;
kgdb_connect(1);
if (kgdb_dev == NODEV) {
printf("no kgdb console.\n");
} else {
kgdb_debug_init = 1;
kgdb_connect(1);
}
}
#endif /* KGDB */
@ -570,37 +574,6 @@ mem_cluster_load()
#endif
}
#ifdef NARLY_MEMORY_PROBE
int
__check_dram(paddr_t start, paddr_t end)
{
u_int8_t *page;
int i, x;
_DPRINTF(" checking...");
for (; start < end; start += NBPG) {
page = (u_int8_t *)SH3_PHYS_TO_P2SEG (start);
x = random();
for (i = 0; i < NBPG; i += 4)
*(volatile int *)(page + i) = (x ^ i);
for (i = 0; i < NBPG; i += 4)
if (*(volatile int *)(page + i) != (x ^ i))
goto bad;
x = random();
for (i = 0; i < NBPG; i += 4)
*(volatile int *)(page + i) = (x ^ i);
for (i = 0; i < NBPG; i += 4)
if (*(volatile int *)(page + i) != (x ^ i))
goto bad;
}
_DPRINTF("success.\n");
return (0);
bad:
_DPRINTF("failed.\n");
return (1);
}
#endif /* NARLY_MEMORY_PROBE */
void
__find_dram_shadow(paddr_t start, paddr_t end)
{
@ -648,3 +621,34 @@ __find_dram_shadow(paddr_t start, paddr_t end)
mem_cluster_cnt++;
}
#ifdef NARLY_MEMORY_PROBE
int
__check_dram(paddr_t start, paddr_t end)
{
u_int8_t *page;
int i, x;
_DPRINTF(" checking...");
for (; start < end; start += NBPG) {
page = (u_int8_t *)SH3_PHYS_TO_P2SEG (start);
x = random();
for (i = 0; i < NBPG; i += 4)
*(volatile int *)(page + i) = (x ^ i);
for (i = 0; i < NBPG; i += 4)
if (*(volatile int *)(page + i) != (x ^ i))
goto bad;
x = random();
for (i = 0; i < NBPG; i += 4)
*(volatile int *)(page + i) = (x ^ i);
for (i = 0; i < NBPG; i += 4)
if (*(volatile int *)(page + i) != (x ^ i))
goto bad;
}
_DPRINTF("success.\n");
return (0);
bad:
_DPRINTF("failed.\n");
return (1);
}
#endif /* NARLY_MEMORY_PROBE */

View File

@ -1,4 +1,4 @@
# $NetBSD: files.sh3,v 1.20 2002/02/28 01:57:01 uch Exp $
# $NetBSD: files.sh3,v 1.21 2002/03/02 22:26:27 uch Exp $
#
# new style config file for sh3 architecture
#
@ -6,7 +6,7 @@
defparam PCLOCK
file arch/sh3/sh3/db_disasm.c ddb
file arch/sh3/sh3/db_interface.c ddb
file arch/sh3/sh3/db_interface.c ddb | kgdb
file arch/sh3/sh3/db_memrw.c ddb | kgdb
file arch/sh3/sh3/db_trace.c ddb
file arch/sh3/sh3/sh3disasm.c ddb

View File

@ -1,4 +1,4 @@
/* $NetBSD: scif.c,v 1.21 2002/02/22 19:44:04 uch Exp $ */
/* $NetBSD: scif.c,v 1.22 2002/03/02 22:26:27 uch Exp $ */
/*-
* Copyright (C) 1999 T.Horiuchi and SAITOH Masanobu. All rights reserved.
@ -116,18 +116,19 @@
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/kgdb.h>
#include <dev/cons.h>
#include <machine/cpu.h>
#include <sh3/clock.h>
#include <sh3/scifreg.h>
//#include <sh3/tmureg.h>
#include <sh3/dev/scifvar.h>
#include <machine/shbvar.h>
static void scifstart(struct tty *);
static int scifparam(struct tty *, struct termios *);
static int kgdb_attached;
void scifcnprobe(struct consdev *);
void scifcninit(struct consdev *);
@ -442,11 +443,16 @@ scif_attach(struct device *parent, struct device *self, void *aux)
irq = ia->ia_irq;
if (scifisconsole) {
if (scifisconsole || kgdb_attached) {
/* InitializeScif(scifcn_speed); */
SET(sc->sc_hwflags, SCIF_HW_CONSOLE);
SET(sc->sc_swflags, TIOCFLAG_SOFTCAR);
printf("\n%s: console\n", sc->sc_dev.dv_xname);
if (kgdb_attached) {
SET(sc->sc_hwflags, SCIF_HW_KGDB);
printf("\n%s: kgdb\n", sc->sc_dev.dv_xname);
} else {
printf("\n%s: console\n", sc->sc_dev.dv_xname);
}
} else {
InitializeScif(9600);
printf("\n");
@ -454,17 +460,10 @@ scif_attach(struct device *parent, struct device *self, void *aux)
callout_init(&sc->sc_diag_ch);
#if 0
if (irq != IRQUNK) {
sc->sc_ih = shb_intr_establish(irq,
IST_EDGE, IPL_SERIAL, scifintr, sc);
}
#else
if (irq != IRQUNK) {
sc->sc_ih = shb_intr_establish(SCIF_IRQ,
IST_EDGE, IPL_SERIAL, scifintr, sc);
}
#endif
SET(sc->sc_hwflags, SCIF_HW_DEV_OK);
@ -720,7 +719,7 @@ scifopen(dev_t dev, int flag, int mode, struct proc *p)
*/
if (ISSET(sc->sc_hwflags, SCIF_HW_KGDB))
return (EBUSY);
#endif
#endif /* KGDB */
tp = sc->sc_tty;
@ -1230,18 +1229,16 @@ scifintr(void *arg)
ssr2 = SHREG_SCSSR2;
if (ISSET(ssr2, SCSSR2_BRK)) {
SHREG_SCSSR2 &= ~(SCSSR2_ER | SCSSR2_BRK | SCSSR2_DR);
#if defined(DDB) || defined(KGDB)
#ifdef DDB
if (ISSET(sc->sc_hwflags, SCIF_HW_CONSOLE)) {
console_debugger();
}
#endif
#endif /* DDB */
#ifdef KGDB
if (ISSET(sc->sc_hwflags, SCIF_HW_KGDB)) {
kgdb_connect(1);
}
#endif
#endif /* DDB || KGDB */
#endif /* KGDB */
}
count = SHREG_SCFDR2 & SCFDR2_RECVCNT;
if (count != 0) {
@ -1484,3 +1481,25 @@ scifcnputc(dev_t dev, int c)
scif_putc((u_char)c);
splx(s);
}
#ifdef KGDB
int
scif_kgdb_init()
{
if (strcmp(kgdb_devname, "scif") != 0)
return (1);
if (scifisconsole)
return (1); /* can't share with console */
InitializeScif(kgdb_rate);
kgdb_attach((int (*)(void *))scifcngetc,
(void (*)(void *, int))scifcnputc, NULL);
kgdb_dev = 123; /* unneeded, only to satisfy some tests */
kgdb_attached = 1;
return (0);
}
#endif /* KGDB */

View File

@ -1,3 +1,4 @@
/* $NetBSD: scifvar.h,v 1.1 2000/02/24 16:42:54 msaitoh Exp $ */
/* $NetBSD: scifvar.h,v 1.2 2002/03/02 22:26:27 uch Exp $ */
extern unsigned int scifcn_speed;
int scif_kgdb_init(void);

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.4 2002/02/08 06:12:00 uch Exp $ */
/* $NetBSD: db_machdep.h,v 1.5 2002/03/02 22:26:27 uch Exp $ */
/*
* Mach Operating System
@ -82,9 +82,9 @@ db_regs_t ddb_regs; /* register state */
/*
* Constants for KGDB.
*/
typedef long kgdb_reg_t;
#define KGDB_NUMREGS 14
#define KGDB_BUFLEN 512
typedef long kgdb_reg_t;
#define KGDB_NUMREGS 59
#define KGDB_BUFLEN 1024
/* macro for checking if a thread has used floating-point */
#define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0)
@ -106,4 +106,6 @@ boolean_t inst_trap_return(int);
*/
#define DB_MACHINE_COMMANDS
extern const char kgdb_devname[];
#endif /* _SH3_DB_MACHDEP_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.10 2002/02/28 01:56:59 uch Exp $ */
/* $NetBSD: db_interface.c,v 1.11 2002/03/02 22:26:27 uch Exp $ */
/*-
* Copyright (C) 2002 UCHIYAMA Yasushi. All rights reserved.
@ -28,6 +28,7 @@
*/
#include "opt_ddb.h"
#include "opt_kgdb.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -38,8 +39,15 @@
#include <machine/cpufunc.h>
#include <machine/db_machdep.h>
#include <ddb/db_run.h>
#include <sh3/ubcreg.h>
extern label_t *db_recover;
extern char *trap_type[];
extern int trap_types;
#ifndef KGDB
#include <sh3/cache.h>
#include <sh3/cache_sh3.h>
#include <sh3/cache_sh4.h>
@ -61,19 +69,6 @@ void db_cachedump_cmd(db_expr_t, int, db_expr_t, char *);
void __db_cachedump_sh3(vaddr_t);
void __db_cachedump_sh4(vaddr_t);
void i_sync_all(db_expr_t, int, db_expr_t, char *);
void i_sync_range_index(db_expr_t, int, db_expr_t, char *);
void i_sync_range(db_expr_t, int, db_expr_t, char *);
void d_wbinv_all(db_expr_t, int, db_expr_t, char *);
void d_wbinv_range_index(db_expr_t, int, db_expr_t, char *);
void d_wbinv_range(db_expr_t, int, db_expr_t, char *);
void d_inv_range(db_expr_t, int, db_expr_t, char *);
void d_wb_range(db_expr_t, int, db_expr_t, char *);
extern label_t *db_recover;
extern char *trap_type[];
extern int trap_types;
const struct db_command db_machine_command_table[] = {
{ "tlb", db_tlbdump_cmd, 0, 0 },
{ "cache", db_cachedump_cmd, 0, 0 },
@ -139,6 +134,7 @@ cpu_Debugger()
__asm__ __volatile__("trapa #0xc3");
}
#endif /* !KGDB */
#define M_BSR 0xf000
#define I_BSR 0xb000
@ -199,6 +195,7 @@ db_clear_single_step(db_regs_t *regs)
regs->tf_ubc = 0;
}
#ifndef KGDB
/*
* MMU
*/
@ -442,3 +439,4 @@ __db_cachedump_sh4(vaddr_t va)
}
#endif /* SH4 */
#undef ON
#endif /* !KGDB */

View File

@ -1,7 +1,7 @@
/* $NetBSD: kgdb_machdep.c,v 1.5 2002/02/19 17:22:34 uch Exp $ */
/* $NetBSD: kgdb_machdep.c,v 1.6 2002/03/02 22:26:27 uch Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* Copyright (c) 1997, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -68,7 +68,6 @@
*/
#include "opt_ddb.h"
#include "opt_kgdb.h"
#if defined(DDB)
#error "Can't build DDB and KGDB together."
@ -77,21 +76,54 @@
/*
* Machine-dependent functions for remote KGDB. Originally written
* for NetBSD/pc532 by Matthias Pfaller. Modified for NetBSD/i386
* by Jason R. Thorpe.
* by Jason R. Thorpe. Modified for NetBSD/mips by Ethan Solomita.
* Modified for NetBSD/sh3 by UCHIYAMA Yasushi.
*/
#include <sys/param.h>
#include <sys/kgdb.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/reboot.h>
#include <sys/kgdb.h>
#include <uvm/uvm_extern.h>
#include <machine/pte.h>
#include <machine/reg.h>
#include <machine/trap.h>
#include <sh3/cpu.h>
/* XXX Should be in <machine/pmap.h> */
pt_entry_t *pmap_pte(pmap_t, vaddr_t);
#include <machine/db_machdep.h>
#include <ddb/db_access.h>
/*
* Is kva a valid address to access? This is used by KGDB.
*/
static int
kvacc(vaddr_t kva)
{
pt_entry_t *pte;
if (kva < SH3_P1SEG_BASE)
return (0);
if (kva < SH3_P2SEG_BASE)
return (1);
if (kva >= VM_MAX_KERNEL_ADDRESS)
return (0);
/* check kva is kernel virtual. */
if ((kva < VM_MIN_KERNEL_ADDRESS) ||
(kva >= VM_MAX_KERNEL_ADDRESS))
return (0);
/* check page which related kva is valid. */
pte = kvtopte(kva);
if (!(*pte & PG_V))
return (0);
return (1);
}
/*
* Determine if the memory at va..(va+len) is valid.
@ -100,18 +132,15 @@ int
kgdb_acc(vaddr_t va, size_t len)
{
vaddr_t last_va;
pt_entry_t pte;
last_va = va + len;
last_va = va + len + NBPG - 1;
va &= ~PGOFSET;
last_va &= ~PGOFSET;
do {
pte = *(pt_entry_t *)pmap_pte(pmap_kernel(), va);
if ((pte & PG_V) == 0)
return (0);
va += NBPG;
} while (va < last_va);
for (; va < last_va; va += NBPG) {
if (kvacc(va) == 0)
return 0;
}
return (1);
}
@ -120,41 +149,38 @@ kgdb_acc(vaddr_t va, size_t len)
* Translate a trap number into a unix compatible signal value.
* (gdb only understands unix signal numbers).
*/
int
int
kgdb_signal(int type)
{
switch (type) {
case T_NMI:
return (SIGINT);
case T_ALIGNFLT:
return (SIGILL);
case T_BPTFLT:
case T_TRCTRAP:
return (SIGTRAP);
case T_ASTFLT:
case T_DOUBLEFLT:
return (SIGEMT);
case T_ARITHTRAP:
case T_DIVIDE:
case T_OFLOW:
case T_DNA:
case T_FPOPFLT:
return (SIGFPE);
case T_PRIVINFLT:
case T_PROTFLT:
case T_PAGEFLT:
case T_TSSFLT:
case T_SEGNPFLT:
case T_STKFLT:
case T_TLBMISSR:
case T_TLBMISSW:
case T_INITPAGEWR:
case T_TLBPRIVR:
case T_TLBPRIVW:
case T_ADDRESSERRR:
case T_ADDRESSERRW:
case T_TLBMISSR+T_USER:
case T_TLBMISSW+T_USER:
case T_INITPAGEWR+T_USER:
case T_TLBPRIVR+T_USER:
case T_TLBPRIVW+T_USER:
case T_ADDRESSERRR+T_USER:
case T_ADDRESSERRW+T_USER:
return (SIGSEGV);
case T_BOUND:
return (SIGURG);
case T_TRAP:
case T_TRAP+T_USER:
case T_USERBREAK:
case T_USERBREAK+T_USER:
return (SIGTRAP);
case T_INVALIDISN:
case T_INVALIDSLOT:
case T_INVALIDISN+T_USER:
case T_INVALIDSLOT+T_USER:
return (SIGILL);
default:
return (SIGEMT);
@ -162,34 +188,40 @@ kgdb_signal(int type)
}
/*
* Translate the values stored in the kernel regs struct to the format
* understood by gdb.
* Translate the values stored in the db_regs_t struct to the format
* understood by gdb. (gdb-5.1.1/gdb/config/sh/tm-sh.h)
*/
void
kgdb_getregs(db_regs_t *regs, kgdb_reg_t *gdb_regs)
{
u_int32_t r;
gdb_regs[ 0] = regs->tf_eax;
gdb_regs[ 1] = regs->tf_ecx;
gdb_regs[ 2] = regs->tf_edx;
gdb_regs[ 3] = regs->tf_ebx;
gdb_regs[ 5] = regs->tf_ebp;
gdb_regs[ 6] = regs->tf_esi;
gdb_regs[ 7] = regs->tf_edi;
gdb_regs[ 8] = regs->tf_eip;
gdb_regs[ 9] = regs->tf_eflags;
gdb_regs[10] = regs->tf_cs;
gdb_regs[12] = regs->tf_ds;
gdb_regs[13] = regs->tf_es;
memset(gdb_regs, 0, KGDB_NUMREGS * sizeof(kgdb_reg_t));
gdb_regs[ 0] = regs->tf_r0;
gdb_regs[ 1] = regs->tf_r1;
gdb_regs[ 2] = regs->tf_r2;
gdb_regs[ 3] = regs->tf_r3;
gdb_regs[ 4] = regs->tf_r4;
gdb_regs[ 5] = regs->tf_r5;
gdb_regs[ 6] = regs->tf_r6;
gdb_regs[ 7] = regs->tf_r7;
gdb_regs[ 8] = regs->tf_r8;
gdb_regs[ 9] = regs->tf_r9;
gdb_regs[10] = regs->tf_r10;
gdb_regs[11] = regs->tf_r11;
gdb_regs[12] = regs->tf_r12;
gdb_regs[13] = regs->tf_r13;
gdb_regs[14] = regs->tf_r14;
gdb_regs[15] = regs->tf_r15;
gdb_regs[16] = regs->tf_spc;
gdb_regs[17] = regs->tf_pr;
__asm__ __volatile__("stc vbr, %0" : "=r"(r));
gdb_regs[19] = r;
gdb_regs[20] = regs->tf_mach;
gdb_regs[21] = regs->tf_macl;
gdb_regs[22] = regs->tf_ssr;
if (KERNELMODE(regs->tf_cs, regs->tf_eflags)) {
/*
* Kernel mode - esp and ss not saved.
*/
gdb_regs[ 4] = (kgdb_reg_t)&regs->tf_esp; /* kernel stack
pointer */
__asm __volatile("movw %%ss,%w0" : "=r" (gdb_regs[11]));
}
/* How treat register bank 1 ? */
}
/*
@ -199,26 +231,28 @@ void
kgdb_setregs(db_regs_t *regs, kgdb_reg_t *gdb_regs)
{
regs->tf_eax = gdb_regs[ 0];
regs->tf_ecx = gdb_regs[ 1];
regs->tf_edx = gdb_regs[ 2];
regs->tf_ebx = gdb_regs[ 3];
regs->tf_ebp = gdb_regs[ 5];
regs->tf_esi = gdb_regs[ 6];
regs->tf_edi = gdb_regs[ 7];
regs->tf_eip = gdb_regs[ 8];
regs->tf_eflags = gdb_regs[ 9];
regs->tf_cs = gdb_regs[10];
regs->tf_ds = gdb_regs[12];
regs->tf_es = gdb_regs[13];
if (KERNELMODE(regs->tf_cs, regs->tf_eflags) == 0) {
/*
* Trapped in user mode - restore esp and ss.
*/
regs->tf_esp = gdb_regs[ 4];
regs->tf_ss = gdb_regs[11];
}
regs->tf_r0 = gdb_regs[ 0];
regs->tf_r1 = gdb_regs[ 1];
regs->tf_r2 = gdb_regs[ 2];
regs->tf_r3 = gdb_regs[ 3];
regs->tf_r4 = gdb_regs[ 4];
regs->tf_r5 = gdb_regs[ 5];
regs->tf_r6 = gdb_regs[ 6];
regs->tf_r7 = gdb_regs[ 7];
regs->tf_r8 = gdb_regs[ 8];
regs->tf_r9 = gdb_regs[ 9];
regs->tf_r10 = gdb_regs[10];
regs->tf_r11 = gdb_regs[11];
regs->tf_r12 = gdb_regs[12];
regs->tf_r13 = gdb_regs[13];
regs->tf_r14 = gdb_regs[14];
regs->tf_r15 = gdb_regs[15];
regs->tf_spc = gdb_regs[16];
regs->tf_pr = gdb_regs[17];
__asm__ __volatile__("ldc %0, vbr" :: "r"(gdb_regs[19]));
regs->tf_mach = gdb_regs[20];
regs->tf_macl = gdb_regs[21];
regs->tf_ssr = gdb_regs[22];
}
/*
@ -229,8 +263,10 @@ void
kgdb_connect(int verbose)
{
if (kgdb_dev < 0)
if (kgdb_dev < 0) {
printf("kgdb_dev=%d\n", kgdb_dev);
return;
}
if (verbose)
printf("kgdb waiting...");
@ -250,6 +286,7 @@ kgdb_connect(int verbose)
void
kgdb_panic()
{
if (kgdb_dev >= 0 && kgdb_debug_panic) {
printf("entering kgdb\n");
kgdb_connect(kgdb_active == 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sh3_machdep.c,v 1.29 2002/02/28 18:18:51 uch Exp $ */
/* $NetBSD: sh3_machdep.c,v 1.30 2002/03/02 22:26:27 uch Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -94,7 +94,11 @@
#ifdef KGDB
#include <sys/kgdb.h>
#ifndef KGDB_DEVNAME
#define KGDB_DEVNAME "nodev"
#endif
const char kgdb_devname[] = KGDB_DEVNAME;
#endif /* KGDB */
#include <uvm/uvm_extern.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.35 2002/02/28 01:56:59 uch Exp $ */
/* $NetBSD: trap.c,v 1.36 2002/03/02 22:26:27 uch Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@ -192,6 +192,11 @@ trap(struct trapframe *tf)
if (kdb_trap(type, 0, tf))
return;
#endif
#ifdef KGDB
if (kgdb_trap(T_USERBREAK, tf))
return;
#endif
if (tf->tf_trapno >> 5 < trap_types)
printf("fatal %s", trap_type[tf->tf_trapno >> 5]);
else