mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-26 22:48:23 +00:00
bsps: Move GDB stubs to bsps
This patch is a part of the BSP source reorganization. Update #3285.
This commit is contained in:
151
bsps/mips/shared/gdbstub/README
Normal file
151
bsps/mips/shared/gdbstub/README
Normal file
@@ -0,0 +1,151 @@
|
||||
/*****************************************************/
|
||||
|
||||
Debugged this stub against the MongooseV bsp. Relies on putting break
|
||||
instructions on breakpoints and step targets- normal stuff, and does not
|
||||
employ hardware breakpoint support at this time. As written, a single
|
||||
breakpoint in a loop will not be reasserted unless the user steps or has
|
||||
a 2nd one, since breakpoints are only reset when the gdb stub is
|
||||
re-entered. A useful enhancement would be to fix the break instruction
|
||||
management so the stub could invisibly put a 2nd break after the 1st
|
||||
"official" one so it can silently reset breakpoints. Shouldn't be too
|
||||
hard, mostly a matter of working it out.
|
||||
|
||||
This was tested only against an R3000 MIPS. It should work OK on a
|
||||
R4000. Needs to be tested at some point.
|
||||
|
||||
This stub supports threads as implemented by gdb 5 and doesn't have any
|
||||
bugs I'm aware of.
|
||||
|
||||
Greg Menke
|
||||
3/5/2002
|
||||
|
||||
/*****************************************************/
|
||||
|
||||
|
||||
The contents of this directory are based upon the "r46kstub.tar.gz" package
|
||||
released to the net by
|
||||
|
||||
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
|
||||
|
||||
This package was released in the September 1996 time frame for use
|
||||
with gdb 4.16 and an IDT R4600 Orion. The stub was modified to support
|
||||
R3000 class CPUs and to work within the mips-rtems exeception processing
|
||||
framework.
|
||||
|
||||
THe file memlimits.h could end up being target board dependent. If
|
||||
this is the case, copy it to your BSP directory and modify as necessary.
|
||||
|
||||
--joel
|
||||
8 February 2002
|
||||
|
||||
Original README
|
||||
===============
|
||||
|
||||
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:
|
||||
194
bsps/mips/shared/gdbstub/gdb_if.h
Normal file
194
bsps/mips/shared/gdbstub/gdb_if.h
Normal file
@@ -0,0 +1,194 @@
|
||||
/**
|
||||
* @file
|
||||
* @ingroup mips_gdb
|
||||
* @brief Definition of the interface between stub and gdb
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup mips_gdb GDB Interface
|
||||
* @ingroup mips_shared
|
||||
* @brief GDB Interface
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _GDB_IF_H
|
||||
#define _GDB_IF_H
|
||||
|
||||
/** @brief Max number of threads in qM response */
|
||||
#define QM_MAX_THREADS (20)
|
||||
|
||||
struct rtems_gdb_stub_thread_info {
|
||||
char display[256];
|
||||
char name[256];
|
||||
char more_display[256];
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Prototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
int parse_zbreak(const char *in, int *type, unsigned char **addr, int *len);
|
||||
|
||||
char* mem2hstr(char *buf, const unsigned char *mem, int count);
|
||||
int hstr2mem(unsigned char *mem, const char *buf, int count);
|
||||
void set_mem_err(void);
|
||||
unsigned char get_byte(const unsigned char *ptr);
|
||||
void set_byte(unsigned char *ptr, int val);
|
||||
char* thread2vhstr(char *buf, int thread);
|
||||
char* thread2fhstr(char *buf, int thread);
|
||||
const char* fhstr2thread(const char *buf, int *thread);
|
||||
const char* vhstr2thread(const char *buf, int *thread);
|
||||
char* int2fhstr(char *buf, int val);
|
||||
char* int2vhstr(char *buf, int vali);
|
||||
const char* fhstr2int(const char *buf, int *ival);
|
||||
const char* vhstr2int(const char *buf, int *ival);
|
||||
int hstr2byte(const char *buf, int *bval);
|
||||
int hstr2nibble(const char *buf, int *nibble);
|
||||
|
||||
Thread_Control *rtems_gdb_index_to_stub_id(int);
|
||||
int rtems_gdb_stub_thread_support_ok(void);
|
||||
int rtems_gdb_stub_get_current_thread(void);
|
||||
int rtems_gdb_stub_get_next_thread(int);
|
||||
int rtems_gdb_stub_get_offsets(
|
||||
unsigned char **text_addr,
|
||||
unsigned char **data_addr,
|
||||
unsigned char **bss_addr
|
||||
);
|
||||
int rtems_gdb_stub_get_thread_regs(
|
||||
int thread,
|
||||
unsigned int *registers
|
||||
);
|
||||
int rtems_gdb_stub_set_thread_regs(
|
||||
int thread,
|
||||
unsigned int *registers
|
||||
);
|
||||
void rtems_gdb_process_query(
|
||||
char *inbuffer,
|
||||
char *outbuffer,
|
||||
int do_threads,
|
||||
int thread
|
||||
);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name MIPS registers
|
||||
* @brief 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
|
||||
|
||||
/** @} */
|
||||
|
||||
void mips_gdb_stub_install(int enableThreads) ;
|
||||
|
||||
#define MEMOPT_READABLE 1
|
||||
#define MEMOPT_WRITEABLE 2
|
||||
|
||||
#ifndef NUM_MEMSEGS
|
||||
#define NUM_MEMSEGS 10
|
||||
#endif
|
||||
|
||||
int gdbstub_add_memsegment(unsigned,unsigned,int);
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* _GDB_IF_H */
|
||||
100
bsps/mips/shared/gdbstub/memlimits.h
Normal file
100
bsps/mips/shared/gdbstub/memlimits.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* @file
|
||||
* @ingroup mips_limits
|
||||
* @brief Definition of machine and system dependent address limits.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 _MEMLIMITS_H_
|
||||
#define _MEMLIMITS_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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup mips_limits Address Limits
|
||||
* @ingroup mips_shared
|
||||
* @brief Address Limits
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
#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))))
|
||||
|
||||
struct memseg
|
||||
{
|
||||
unsigned begin, end, opts;
|
||||
};
|
||||
|
||||
#define MEMOPT_READABLE 1
|
||||
#define MEMOPT_WRITEABLE 2
|
||||
|
||||
#define NUM_MEMSEGS 10
|
||||
|
||||
int add_memsegment(unsigned,unsigned,int);
|
||||
int is_readable(unsigned,unsigned);
|
||||
int is_writeable(unsigned,unsigned);
|
||||
int is_steppable(unsigned);
|
||||
*/
|
||||
|
||||
#endif /* _MEMLIMITS_H_ */
|
||||
1589
bsps/mips/shared/gdbstub/mips-stub.c
Normal file
1589
bsps/mips/shared/gdbstub/mips-stub.c
Normal file
File diff suppressed because it is too large
Load Diff
336
bsps/mips/shared/gdbstub/mips_opcode.h
Normal file
336
bsps/mips/shared/gdbstub/mips_opcode.h
Normal file
@@ -0,0 +1,336 @@
|
||||
/**
|
||||
* @file
|
||||
* @ingroup
|
||||
* @brief Instruction formats and opcode values for MIPS
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Ralph Campbell.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)mips_opcode.h 7.1 (Berkeley) 3/19/92
|
||||
* via: mips_opcode.h,v 1.1 1994/03/10 16:15:10 (algorithmics)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define the instruction formats and opcode values for the
|
||||
* MIPS instruction set.
|
||||
*/
|
||||
|
||||
#ifndef _MIPS_OPCODE_H
|
||||
#define _MIPS_OPCODE_H
|
||||
|
||||
/**
|
||||
* @defgroup mips_ops MIPS Opcodes
|
||||
* @ingroup mips_shared
|
||||
* @brief MIPS Instruction Formats and Opcode Values
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name Instruction formats
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef union {
|
||||
unsigned word;
|
||||
|
||||
#ifdef MIPSEL
|
||||
struct {
|
||||
unsigned imm: 16;
|
||||
unsigned rt: 5;
|
||||
unsigned rs: 5;
|
||||
unsigned op: 6;
|
||||
} IType;
|
||||
|
||||
struct {
|
||||
unsigned target: 26;
|
||||
unsigned op: 6;
|
||||
} JType;
|
||||
|
||||
struct {
|
||||
unsigned func: 6;
|
||||
unsigned shamt: 5;
|
||||
unsigned rd: 5;
|
||||
unsigned rt: 5;
|
||||
unsigned rs: 5;
|
||||
unsigned op: 6;
|
||||
} RType;
|
||||
|
||||
struct {
|
||||
unsigned func: 6;
|
||||
unsigned fd: 5;
|
||||
unsigned fs: 5;
|
||||
unsigned ft: 5;
|
||||
unsigned fmt: 4;
|
||||
unsigned : 1; /* always '1' */
|
||||
unsigned op: 6; /* always '0x11' */
|
||||
} FRType;
|
||||
#else
|
||||
struct {
|
||||
unsigned op: 6;
|
||||
unsigned rs: 5;
|
||||
unsigned rt: 5;
|
||||
unsigned imm: 16;
|
||||
} IType;
|
||||
|
||||
struct {
|
||||
unsigned op: 6;
|
||||
unsigned target: 26;
|
||||
} JType;
|
||||
|
||||
struct {
|
||||
unsigned op: 6;
|
||||
unsigned rs: 5;
|
||||
unsigned rt: 5;
|
||||
unsigned rd: 5;
|
||||
unsigned shamt: 5;
|
||||
unsigned func: 6;
|
||||
} RType;
|
||||
|
||||
struct {
|
||||
unsigned op: 6; /* always '0x11' */
|
||||
unsigned : 1; /* always '1' */
|
||||
unsigned fmt: 4;
|
||||
unsigned func: 6;
|
||||
unsigned ft: 5;
|
||||
unsigned fs: 5;
|
||||
unsigned fd: 5;
|
||||
} FRType;
|
||||
#endif
|
||||
} InstFmt;
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name 'op' field values
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OP_SPECIAL 000
|
||||
#define OP_REGIMM 001
|
||||
#define OP_J 002
|
||||
#define OP_JAL 003
|
||||
#define OP_BEQ 004
|
||||
#define OP_BNE 005
|
||||
#define OP_BLEZ 006
|
||||
#define OP_BGTZ 007
|
||||
|
||||
#define OP_ADDI 010
|
||||
#define OP_ADDIU 011
|
||||
#define OP_SLTI 012
|
||||
#define OP_SLTIU 013
|
||||
#define OP_ANDI 014
|
||||
#define OP_ORI 015
|
||||
#define OP_XORI 016
|
||||
#define OP_LUI 017
|
||||
|
||||
#define OP_COP0 020
|
||||
#define OP_COP1 021
|
||||
#define OP_COP2 022
|
||||
#define OP_BEQL 024
|
||||
#define OP_BNEL 025
|
||||
#define OP_BLEZL 026
|
||||
#define OP_BGTZL 027
|
||||
|
||||
#define OP_DADDI 030
|
||||
#define OP_DADDIU 031
|
||||
#define OP_LDL 032
|
||||
#define OP_LDR 033
|
||||
|
||||
#define OP_LB 040
|
||||
#define OP_LH 041
|
||||
#define OP_LWL 042
|
||||
#define OP_LW 043
|
||||
#define OP_LBU 044
|
||||
#define OP_LHU 045
|
||||
#define OP_LWR 046
|
||||
#define OP_LWU 047
|
||||
|
||||
#define OP_SB 050
|
||||
#define OP_SH 051
|
||||
#define OP_SWL 052
|
||||
#define OP_SW 053
|
||||
#define OP_SDL 054
|
||||
#define OP_SDR 055
|
||||
#define OP_SWR 056
|
||||
#define OP_CACHE 057
|
||||
|
||||
#define OP_LL 060
|
||||
#define OP_LWC1 061
|
||||
#define OP_LWC2 062
|
||||
#define OP_LLD 064
|
||||
#define OP_LDC1 065
|
||||
#define OP_LDC2 066
|
||||
#define OP_LD 067
|
||||
|
||||
#define OP_SC 070
|
||||
#define OP_SWC1 071
|
||||
#define OP_SWC2 072
|
||||
#define OP_SCD 074
|
||||
#define OP_SDC1 075
|
||||
#define OP_SDC2 076
|
||||
#define OP_SD 077
|
||||
|
||||
/**
|
||||
* @name 'func' field values when 'op' == OP_SPECIAL.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OP_SLL 000
|
||||
#define OP_SRL 002
|
||||
#define OP_SRA 003
|
||||
#define OP_SLLV 004
|
||||
#define OP_SRLV 006
|
||||
#define OP_SRAV 007
|
||||
|
||||
#define OP_JR 010
|
||||
#define OP_JALR 011
|
||||
#define OP_SYSCALL 014
|
||||
#define OP_BREAK 015
|
||||
#define OP_SYNC 017
|
||||
|
||||
#define OP_MFHI 020
|
||||
#define OP_MTHI 021
|
||||
#define OP_MFLO 022
|
||||
#define OP_MTLO 023
|
||||
#define OP_DSLLV 024
|
||||
#define OP_DSRLV 026
|
||||
#define OP_DSRAV 027
|
||||
|
||||
#define OP_MULT 030
|
||||
#define OP_MULTU 031
|
||||
#define OP_DIV 032
|
||||
#define OP_DIVU 033
|
||||
#define OP_DMULT 034
|
||||
#define OP_DMULTU 035
|
||||
#define OP_DDIV 036
|
||||
#define OP_DDIVU 037
|
||||
|
||||
#define OP_ADD 040
|
||||
#define OP_ADDU 041
|
||||
#define OP_SUB 042
|
||||
#define OP_SUBU 043
|
||||
#define OP_AND 044
|
||||
#define OP_OR 045
|
||||
#define OP_XOR 046
|
||||
#define OP_NOR 047
|
||||
|
||||
#define OP_SLT 052
|
||||
#define OP_SLTU 053
|
||||
#define OP_DADD 054
|
||||
#define OP_DADDU 055
|
||||
#define OP_DSUB 056
|
||||
#define OP_DSUBU 057
|
||||
|
||||
#define OP_TGE 060
|
||||
#define OP_TGEU 061
|
||||
#define OP_TLT 062
|
||||
#define OP_TLTU 063
|
||||
#define OP_TEQ 064
|
||||
#define OP_TNE 066
|
||||
|
||||
#define OP_DSLL 070
|
||||
#define OP_DSRL 072
|
||||
#define OP_DSRA 073
|
||||
#define OP_DSLL32 074
|
||||
#define OP_DSRL32 076
|
||||
#define OP_DSRA32 077
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* 'func' field values when 'op' == OP_REGIMM.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OP_BLTZ 000
|
||||
#define OP_BGEZ 001
|
||||
#define OP_BLTZL 002
|
||||
#define OP_BGEZL 003
|
||||
|
||||
#define OP_TGEI 010
|
||||
#define OP_TGEIU 011
|
||||
#define OP_TLTI 012
|
||||
#define OP_TLTIU 013
|
||||
#define OP_TEQI 014
|
||||
#define OP_TNEI 016
|
||||
|
||||
#define OP_BLTZAL 020
|
||||
#define OP_BGEZAL 021
|
||||
#define OP_BLTZALL 022
|
||||
#define OP_BGEZALL 023
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name 'rs' field values when 'op' == OP_COPz.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OP_MF 000
|
||||
#define OP_DMF 001
|
||||
#define OP_CF 002
|
||||
#define OP_MT 004
|
||||
#define OP_DMT 005
|
||||
#define OP_CT 006
|
||||
#define OP_BC 010
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name 'rt' field values when 'op' == OP_COPz and 'rt' == OP_BC.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define COPz_BCF 0x00
|
||||
#define COPz_BCT 0x01
|
||||
#define COPz_BCFL 0x02
|
||||
#define COPz_BCTL 0x03
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Instructions with specal significance to debuggers.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define BREAK_INSTR 0x0000000d ///< @brief instruction code for break
|
||||
#define NOP_INSTR 0x00000000 ///< @brief instruction code for no-op
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* _MIPS_OPCODE_H */
|
||||
Reference in New Issue
Block a user