2002-02-08 Joel Sherrill <joel@OARcorp.com>

* Merged r46kstub.c into RTEMS distribution without modification.
	I got the code from Franz Fischer <Franz.Fischer@franz-fischer.de>
	who had used this with an old version of RTEMS with the mips64orion
	port of RTEMS.  After adding this to the repository, I will tailor
	this to work with the RTEMS exception processing model and trim
	no longer needed parts.
	* ChangeLog, gdb_if.h, ioaddr.h, limits.h, Makefile, mips_opcode.h,
	r4600.h, r46kstub.c, r46kstub.ld, README, stubinit.S:
This commit is contained in:
Joel Sherrill committed 2002-02-08 20:03:26 +00:00
1 parent 9b116329db
commit fb63984771
11 files changed
+2664

No files matched your search

@@ -0,0 +1,43 @@
2002-02-08 Joel Sherrill <joel@OARcorp.com>
* Merged r46kstub.c into RTEMS distribution without modification.
I got the code from Franz Fischer <Franz.Fischer@franz-fischer.de>
who had used this with an old version of RTEMS with the mips64orion
port of RTEMS. After adding this to the repository, I will tailor
this to work with the RTEMS exception processing model and trim
no longer needed parts.
* ChangeLog, gdb_if.h, ioaddr.h, limits.h, Makefile, mips_opcode.h,
r4600.h, r46kstub.c, r46kstub.ld, README, stubinit.S:
Sun Sep 29 16:34:53 1996 C. M. Heard <heard@vvnet.com>
* Updated snapshot posted.
* stubinit.S (_reset_exception, _general_exception): Reorder
instructions or insert nops as necessary to ensure that the
target register of mfc0, mfc1, and cfc1 instructions is not
used as a source register in the load delay slot of those
instructions and to ensure that the instruction following
mtc0 is always something other than mfc0. Insert .eject
directives and reformat some of the comments to make the
assembler listing more readable.
* ioaddr.h: add comments pointing out implementation-
specific address definitions.
* limits.h: add comments describing what the implementation-
specific macros in this file are supposed to do.
Tue Aug 06 14:43:04 1995 C. M. Heard <heard@vvnet.com>
* Updated snapshot posted.
* stubinit.S (_general_exception): Use virtual adresses from
kseg0 (cached, unmapped space) instead of kseg1 (uncached,
unmapped space) in cache instructions.
(_reset_exception): Likewise, and use the right
mask to clean the K0 field in the config register.
Fri Jul 26 14:41:49 1995 C. M. Heard <heard@vvnet.com>
* Initial snapshot posted.
@@ -0,0 +1,38 @@
CC = mips64orion-idt-elf-gcc
CFLAGS = -g -Wa,-ahld -Wall -membedded-data -O3
AS = mips64orion-idt-elf-as
ASFLAGS = -ahld
LD = mips64orion-idt-elf-ld
LDFLAGS = -t -s
# Inference rules
.SUFFIXES: $(SUFFIXES) .out .ld
.ld.out:
$(LD) $(LDFLAGS) -T $< -Map $*.map -o $*.out
.c.o:
$(CC) $(CFLAGS) -c $< >$*.L
.S.o:
$(CC) $(CFLAGS) -c $< >$*.L
.s.o:
$(AS) $(ASFLAGS) -o $*.o $< >$*.L
# Targets
r46kstub.hex: r46kstub.out
mips64orion-idt-elf-objcopy -S -R .bss -R .data -R .reginfo \
-O srec r46kstub.out r46kstub.hex
clean:
rm -f *.L *.map *.o *.out *.hex
# Dependencies
r46kstub.out: r46kstub.ld r46kstub.o stubinit.o
r46kstub.o: mips_opcode.h r4600.h limits.h gdb_if.h r46kstub.c
stubinit.o: r4600.h ioaddr.h gdb_if.h stubinit.S
+115
View File
@@ -0,0 +1,115 @@
/* r46kstub 9/29/96 c. m. heard */
/* 7/26/96 -- original posting */
/* 8/06/96 -- cache initialization/flushing logic fixed */
/* 9/29/96 -- coprocessor load delay slots respected, documentation improved */
The r46kstub directory and its compressed archive (r46kstub.tar.gz) contain
the 9/29/96 source code snapshot for a ROM-resident gdb-4.16 debug agent
(aka stub) for the IDT R4600 Orion processor. It is based on the stub for
the Hitachi SH processor written by Ben Lee and Steve Chamberlain and
supplied with the gdb-4.16 distribution; that stub in turn was "originally
based on an m68k software stub written by Glenn Engel at HP, but has changed
quite a bit". The modifications for the R4600 were contributed by C. M.
Heard of VVNET, Inc. and were based in part on the Algorithmics R4000 version
of Phil Bunce's PMON program.
The distribution consists of the following files:
-rw-r--r-- 1 1178 Sep 29 16:34 ChangeLog
-rw-r--r-- 1 748 Jul 26 01:18 Makefile
-rw-r--r-- 1 6652 Sep 29 16:34 README
-rw-r--r-- 1 1829 May 21 02:02 gdb_if.h
-rw-r--r-- 1 3745 Sep 29 14:03 ioaddr.h
-rw-r--r-- 1 2906 Sep 29 14:39 limits.h
-rw-r--r-- 1 6552 May 23 00:17 mips_opcode.h
-rw-r--r-- 1 14017 May 21 02:04 r4600.h
-rw-r--r-- 1 23874 Jul 21 20:31 r46kstub.c
-rw-r--r-- 1 1064 Jul 3 12:35 r46kstub.ld
-rw-r--r-- 1 13299 Sep 29 16:24 stubinit.S
With the exception of mips_opcode.h, which is a slightly modified version
of a header file contributed by Ralph Campbell to 4.4 BSD and is therefore
copyrighted by the UC Regents, all of the source files have been dedicated
by their authors to the public domain. Use them as you wish, but do so
at your own risk! The authors accept _no_ responsibility for any errors.
The debug agent contained herein is at this writing in active use at VVNET
supporting initial hardware debug and board bring-up of an OC-12 ATM probe
board. It uses polled I/O on a 16C450 UART. We had originally intended to
add support for interrupts to allow gdb to break in on a running program,
but we have found that this is not really necessary since the reset button
will accomplish the same purpose (thanks to the MIPS feature of saving the
program counter in the ErrorEPC register when a reset exception occurs).
Be aware that this stub handles ALL interrupts and exceptions except for
reset (or NMI) in the same way -- by passing control to the debug command
loop. It of course uses the ROM exception vectors to do so. In order to
support code that actally needs to use interrupts we use use a more elaborate
stub that is linked with the downloaded program. It hooks the RAM exception
vectors and clears the BEV status bit to gain control. The ROM-based stub
is still used in this case for initial program loading.
In order to port this stub to a different platform you will at a minimum
need to customize the macros in limits.h (which define the limits of readable,
writeable, and steppable address space) and the I/O addresses in ioaddr.h
(which define the 16C450 MMIO addresses). If you use something other than
a 16C450 UART you will probably also need to modify the portions of stubinit.S
which deal with the serial port. I've tried to be careful to respect all the
architecturally-defined hazards as described in Appendix F of Kane and
Heinrich, MIPS RISC Architecture, in order to minimize the work in porting
to 4000-series processors other than the R4600, but no guarantees are offered.
Support is presently restricted to big-endian addressing, and I've not even
considered what changes would be needed for little-endian support.
When this stub is built with gcc-2.7.2 and binutils-2.6 you will see a few
warning messages from the single-step support routine where a cast is used
to sign-extend a pointer (the next instruction address) into a long long
(the PC image). Those warnings are expected; I've checked the generated
code and it is doing what I had intended. But you should not see any other
warnings or errors. Here is a log of the build:
mips64orion-idt-elf-gcc -g -Wa,-ahld -Wall -membedded-data \
-O3 -c r46kstub.c >r46kstub.L
r46kstub.c: In function `doSStep':
r46kstub.c:537: warning: cast to pointer from integer of different size
r46kstub.c:539: warning: cast to pointer from integer of different size
r46kstub.c:547: warning: cast to pointer from integer of different size
r46kstub.c:561: warning: cast to pointer from integer of different size
r46kstub.c:563: warning: cast to pointer from integer of different size
r46kstub.c:572: warning: cast to pointer from integer of different size
r46kstub.c:574: warning: cast to pointer from integer of different size
r46kstub.c:582: warning: cast to pointer from integer of different size
r46kstub.c:589: warning: cast to pointer from integer of different size
r46kstub.c:591: warning: cast to pointer from integer of different size
r46kstub.c:597: warning: cast to pointer from integer of different size
r46kstub.c:599: warning: cast to pointer from integer of different size
r46kstub.c:605: warning: cast to pointer from integer of different size
r46kstub.c:607: warning: cast to pointer from integer of different size
r46kstub.c:613: warning: cast to pointer from integer of different size
r46kstub.c:615: warning: cast to pointer from integer of different size
r46kstub.c:624: warning: cast to pointer from integer of different size
r46kstub.c:628: warning: cast to pointer from integer of different size
r46kstub.c:635: warning: cast to pointer from integer of different size
r46kstub.c:637: warning: cast to pointer from integer of different size
mips64orion-idt-elf-gcc -g -Wa,-ahld -Wall -membedded-data \
-O3 -c stubinit.S >stubinit.L
mips64orion-idt-elf-ld -t -s -T r46kstub.ld -Map r46kstub.map -o r46kstub.out
mips64orion-idt-elf-ld: mode elf32bmip
stubinit.o
r46kstub.o
mips64orion-idt-elf-objcopy -S -R .bss -R .data -R .reginfo \
-O srec r46kstub.out r46kstub.hex
Limitations: stubinit.S deliberately forces the PC (which is a 64-bit
register) to contain a legitimate sign-extended 32-bit value. This was
done to cope with a bug in gdb-4.16, which does _not_ properly sign-extend
the initial PC when it loads a program. This means that you cannot use
the "set" command to load an unmapped sixty-four bit virtual address into
the PC, as you can for all other registers.
Please send bug reports, comments, or suggestions for improvement to:
C. M. Heard
VVNET, Inc. phone: +1 408 247 9376
4040 Moorpark Ave. Suite 206 fax: +1 408 244 3651
San Jose, CA 95117 USA e-mail: heard@vvnet.com
@@ -0,0 +1,105 @@
/*
* gdb_if.h - definition of the interface between the stub and gdb
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* The following software is offered for use in the public domain.
* There is no warranty with regard to this software or its performance
* and the user must accept the software "AS IS" with all faults.
*
* THE CONTRIBUTORS DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, WITH
* REGARD TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef _GDB_IF_H
#define _GDB_IF_H
/*
* R4600 registers, numbered in the order in which gdb expects to see them.
*/
#define ZERO 0
#define AT 1
#define V0 2
#define V1 3
#define A0 4
#define A1 5
#define A2 6
#define A3 7
#define T0 8
#define T1 9
#define T2 10
#define T3 11
#define T4 12
#define T5 13
#define T6 14
#define T7 15
#define S0 16
#define S1 17
#define S2 18
#define S3 19
#define S4 20
#define S5 21
#define S6 22
#define S7 23
#define T8 24
#define T9 25
#define K0 26
#define K1 27
#define GP 28
#define SP 29
#define S8 30
#define RA 31
#define SR 32
#define LO 33
#define HI 34
#define BAD_VA 35
#define CAUSE 36
#define PC 37
#define F0 38
#define F1 39
#define F2 40
#define F3 41
#define F4 42
#define F5 43
#define F6 44
#define F7 45
#define F8 46
#define F9 47
#define F10 48
#define F11 49
#define F12 50
#define F13 51
#define F14 52
#define F15 53
#define F16 54
#define F17 55
#define F18 56
#define F19 57
#define F20 58
#define F21 59
#define F22 60
#define F23 61
#define F24 62
#define F25 63
#define F26 64
#define F27 65
#define F28 66
#define F29 67
#define F30 68
#define F31 69
#define FCSR 70
#define FIRR 71
#define NUM_REGS 72
#endif /* _GDB_IF_H */
@@ -0,0 +1,113 @@
/*
* ioaddr.h - 16C450 serial port memory-mapped I/O address definitions
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* The following software is offered for use in the public domain.
* There is no warranty with regard to this software or its performance
* and the user must accept the software "AS IS" with all faults.
*
* THE CONTRIBUTORS DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, WITH
* REGARD TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef _IOADDR_H
#define _IOADDR_H
/*
* The following addresses are implementation-specific.
* Note that big-endian memory addressing is assumed.
*/
#define ISA_IO_BASE 0xb8000000
#define BYTE_IO(ioaddr) ((ioaddr<<3)+7)
#define WORD_IO(ioaddr) ((ioaddr<<3)+6)
#define ISA_IRQ9_RESET 0xb8043000
#define ISA_IRQ5_RESET 0xb8042000
#define ISA_IRQ4_RESET 0xb8041000
#define ISA_IRQ3_RESET 0xb8040000
#define ISA_IRQ_STATUS 0xb8040000
/* ISA IRQ Status Register fields */
#define ISA_IRQ9_STATUS 0x08
#define ISA_IRQ5_STATUS 0x04
#define ISA_IRQ4_STATUS 0x02
#define ISA_IRQ3_STATUS 0x01
/*
* Serial Port 1 (COM1) I/O Addresses. These definitions
* follows the standard IBM AT I/O address assignments.
* Note that IRQ4 is normally assigned to serial port 1.
*/
#define DIV_LO_COM1 BYTE_IO(0x3f8) /* Div latch lo (line ctl bit 7 = 1) */
#define DIV_HI_COM1 BYTE_IO(0x3f9) /* Div latch hi (line ctl bit 7 = 1) */
#define DATA_REG_COM1 BYTE_IO(0x3f8) /* TX Buf (write)/RX Buf (read) */
#define INT_ENA_COM1 BYTE_IO(0x3f9) /* Interrupt Enable Register */
#define INT_ID_COM1 BYTE_IO(0x3fa) /* Interrupt ID Register */
#define LINE_CTL_COM1 BYTE_IO(0x3fb) /* Line Control Register */
#define MODEM_CTL_COM1 BYTE_IO(0x3fc) /* Modem Control Register */
#define LINE_STS_COM1 BYTE_IO(0x3fd) /* Line Status Register */
#define MODEM_STS_COM1 BYTE_IO(0x3fe) /* Modem Status Register */
/*
* Serial Port 2 (COM1) I/O Addresses. These definitions
* follows the standard IBM AT I/O address assignments.
* Note that IRQ3 is normally assigned to serial port 2.
*/
#define DIV_LO_COM2 BYTE_IO(0x2f8) /* Div latch lo (line ctl bit 7 = 1) */
#define DIV_HI_COM2 BYTE_IO(0x2f9) /* Div latch hi (line ctl bit 7 = 1) */
#define DATA_REG_COM2 BYTE_IO(0x2f8) /* TX Buf (write)/RX Buf (read) */
#define INT_ENA_COM2 BYTE_IO(0x2f9) /* Interrupt Enable Register */
#define INT_ID_COM2 BYTE_IO(0x2fa) /* Interrupt ID Register */
#define LINE_CTL_COM2 BYTE_IO(0x2fb) /* Line Control Register */
#define MODEM_CTL_COM2 BYTE_IO(0x2fc) /* Modem Control Register */
#define LINE_STS_COM2 BYTE_IO(0x2fd) /* Line Status Register */
#define MODEM_STS_COM2 BYTE_IO(0x2fe) /* Modem Status Register */
/* Interrupt Enable Register fields */
#define IENA_MODEM 0x08
#define IENA_LINE 0x04
#define IENA_TX 0x02
#define IENA_RX 0x01
/* Interrupt Identification Register fields */
#define INT_ID_MASK 0x06
#define INT_PENDING 0x01
/* Line Control Register fields */
#define DIV_LATCH_EN 0x80
#define SET_BREAK 0x40
#define STICK_PARITY 0x20
#define EVEN_PARITY 0x10
#define PARITY_ENA 0x08
#define STOP_BITS 0x04
#define WORD_LEN_MASK 0x03
/* Line Status Register fields */
#define TX_SHR_EMPTY 0x40
#define TX_BUF_EMPTY 0x20
#define BRK_RCVD 0x10
#define FRAMING_ERR 0x08
#define PARITY_ERR 0x04
#define OVRUN_ERR 0x02
#define RX_CHAR_AVA 0x01
/* Modem Control Register fields */
#define LOOPBACK 0x10
#define OUT2 0x08
#define OUT1 0x04
#define RTS 0x02
#define DTR 0x01
/* Modem Status Register fields */
#define RLSD 0x80
#define RI 0x40
#define DSR 0x20
#define CTS 0x10
#define DELTA_RLSD 0x08
#define TRAIL_EDGE_RI 0x04
#define DELTA_DSR 0x02
#define DELTA_CTS 0x01
#endif /* _IOADDR_H */
@@ -0,0 +1,70 @@
/*
* limits.h - definition of machine & system dependent address limits
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* The following software is offered for use in the public domain.
* There is no warranty with regard to this software or its performance
* and the user must accept the software "AS IS" with all faults.
*
* THE CONTRIBUTORS DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, WITH
* REGARD TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef _LIMITS_H_
#define _LIMITS_H_
/*
* The macros in this file are specific to a given implementation.
* The general rules for their construction are as follows:
*
* 1.) is_readable(addr,length) should be true if and only if the
* region starting at the given virtual address can be read
* _without_ causing an exception or other fatal error. Note
* that the stub will use the strictest alignment satisfied
* by _both_ addr and length (e.g., if both are divisible by
* 8 then the region will be read in double-word chunks).
*
* 2.) is_writeable(addr,length) should be true if and only if the
* region starting at the given virtual address can be written
* _without_ causing an exception or other fatal error. Note
* that the stub will use the strictest alignment satisfied
* by _both_ addr and length (e.g., if both are divisible by
* 8 then the region will be written in double-word chunks).
*
* 3.) is-steppable(ptr) whould be true if and only if ptr is the
* address of a writeable region of memory which may contain
* an executable instruction. At a minimum this requires that
* ptr be word-aligned (divisible by 4) and not point to EPROM
* or memory-mapped I/O.
*
* Note: in order to satisfy constraints related to cacheability
* of certain memory subsystems it may be necessary for regions
* of kseg0 and kseg1 which map to the same physical addresses
* to have different readability and/or writeability attributes.
*/
#define K0_LIMIT_FOR_READ (K0BASE+0x18000000)
#define K1_LIMIT_FOR_READ (K1BASE+K1SIZE)
#define is_readable(addr,length) \
(((K0BASE <= addr) && ((addr + length) <= K0_LIMIT_FOR_READ)) \
|| ((K1BASE <= addr) && ((addr + length) <= K1_LIMIT_FOR_READ)))
#define K0_LIMIT_FOR_WRITE (K0BASE+0x08000000)
#define K1_LIMIT_FOR_WRITE (K1BASE+0x1e000000)
#define is_writeable(addr,length) \
(((K0BASE <= addr) && ((addr + length) <= K0_LIMIT_FOR_WRITE)) \
|| ((K1BASE <= addr) && ((addr + length) <= K1_LIMIT_FOR_WRITE)))
#define K0_LIMIT_FOR_STEP (K0BASE+0x08000000)
#define K1_LIMIT_FOR_STEP (K1BASE+0x08000000)
#define is_steppable(ptr) \
((((int)ptr & 0x3) == 0) \
&& (((K0BASE <= (int)ptr) && ((int)ptr < K0_LIMIT_FOR_STEP)) \
|| ((K1BASE <= (int)ptr) && ((int)ptr < K1_LIMIT_FOR_STEP))))
#endif /* _LIMITS_H_ */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,53 @@
MEMORY
{
NUL : ORIGIN = 0xa00f0000, LENGTH = 0
RAM : ORIGIN = 0xa00fe000, LENGTH = 8K
ROM : ORIGIN = 0xbfc00000, LENGTH = 8K
}
SECTIONS
{
/* Initialized data is _not_ supported. */
/* Assign it to an empty region in order */
/* to force a link error if any exists. */
.data 0xa00f0000 (NOLOAD): {
_fdata = .;
*(.data)
. = ALIGN(8);
_gp = . + 0x8000;
*(.sdata)
. = ALIGN(8);
_edata = .;
} >NUL
/* Assign uninitialized read/write data to RAM. */
.bss 0xa00fe000 (NOLOAD): {
_fbss = .;
stubinit.o(.bss)
*(.sbss)
*(.bss)
*(.scommon)
*(COMMON)
. = ALIGN(8);
_end = .;
} >RAM
/* Assign code and read-only data to ROM. This */
/* section MUST start at the reset address, */
/* and the reset code MUST be linked first. */
.text 0xbfc00000: {
_ftext = .;
stubinit.o(.text)
. = ALIGN(8);
r46kstub.o(.text)
. = ALIGN(8);
*(.rdata)
. = ALIGN(8);
*(.rodata)
. = ALIGN(8);
_etext = .;
} >ROM = 0
}
ENTRY(_reset_exception)
File diff suppressed because it is too large. Load diff