| 1 | /* Interface definition for configurable Xtensa ISA support.
|
|---|
| 2 | Copyright 2003 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of BFD, the Binary File Descriptor library.
|
|---|
| 5 |
|
|---|
| 6 | This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 9 | (at your option) any later version.
|
|---|
| 10 |
|
|---|
| 11 | This program is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with this program; if not, write to the Free Software
|
|---|
| 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|---|
| 19 |
|
|---|
| 20 | #ifndef XTENSA_LIBISA_H
|
|---|
| 21 | #define XTENSA_LIBISA_H
|
|---|
| 22 |
|
|---|
| 23 | /* Use the statically-linked version for the GNU tools. */
|
|---|
| 24 | #define STATIC_LIBISA 1
|
|---|
| 25 |
|
|---|
| 26 | #ifdef __cplusplus
|
|---|
| 27 | extern "C" {
|
|---|
| 28 | #endif
|
|---|
| 29 |
|
|---|
| 30 | #ifndef uint32
|
|---|
| 31 | #define uint32 unsigned int
|
|---|
| 32 | #endif
|
|---|
| 33 |
|
|---|
| 34 | /* This file defines the interface to the Xtensa ISA library. This library
|
|---|
| 35 | contains most of the ISA-specific information for a particular Xtensa
|
|---|
| 36 | processor. For example, the set of valid instructions, their opcode
|
|---|
| 37 | encodings and operand fields are all included here. To support Xtensa's
|
|---|
| 38 | configurability and user-defined instruction extensions (i.e., TIE), the
|
|---|
| 39 | library is initialized by loading one or more dynamic libraries; only a
|
|---|
| 40 | small set of interface code is present in the statically-linked portion
|
|---|
| 41 | of the library.
|
|---|
| 42 |
|
|---|
| 43 | This interface basically defines four abstract data types.
|
|---|
| 44 |
|
|---|
| 45 | . an instruction buffer - for holding the raw instruction bits
|
|---|
| 46 | . ISA info - information about the ISA as a whole
|
|---|
| 47 | . opcode info - information about individual instructions
|
|---|
| 48 | . operand info - information about specific instruction operands
|
|---|
| 49 |
|
|---|
| 50 | It would be nice to implement these as classes in C++, but the library is
|
|---|
| 51 | implemented in C to match the expectations of the GNU tools.
|
|---|
| 52 | Instead, the interface defines a set of functions to access each data
|
|---|
| 53 | type. With the exception of the instruction buffer, the internal
|
|---|
| 54 | representations of the data structures are hidden. All accesses must be
|
|---|
| 55 | made through the functions defined here. */
|
|---|
| 56 |
|
|---|
| 57 | typedef void* xtensa_isa;
|
|---|
| 58 | typedef void* xtensa_operand;
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | /* Opcodes are represented here using sequential integers beginning with 0.
|
|---|
| 62 | The specific value used for a particular opcode is only fixed for a
|
|---|
| 63 | particular instantiation of an xtensa_isa structure, so these values
|
|---|
| 64 | should only be used internally. */
|
|---|
| 65 | typedef int xtensa_opcode;
|
|---|
| 66 |
|
|---|
| 67 | /* Define a unique value for undefined opcodes ("static const int" doesn't
|
|---|
| 68 | seem to work for this because EGCS 1.0.3 on i686-Linux without -O won't
|
|---|
| 69 | allow it to be used as an initializer). */
|
|---|
| 70 | #define XTENSA_UNDEFINED -1
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | typedef int libisa_module_specifier;
|
|---|
| 74 |
|
|---|
| 75 | extern xtensa_isa xtensa_isa_init (void);
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 | /* Instruction buffers. */
|
|---|
| 79 |
|
|---|
| 80 | typedef uint32 xtensa_insnbuf_word;
|
|---|
| 81 | typedef xtensa_insnbuf_word *xtensa_insnbuf;
|
|---|
| 82 |
|
|---|
| 83 | /* Get the size in words of the xtensa_insnbuf array. */
|
|---|
| 84 | extern int xtensa_insnbuf_size (xtensa_isa);
|
|---|
| 85 |
|
|---|
| 86 | /* Allocate (with malloc) an xtensa_insnbuf of the right size. */
|
|---|
| 87 | extern xtensa_insnbuf xtensa_insnbuf_alloc (xtensa_isa);
|
|---|
| 88 |
|
|---|
| 89 | /* Release (with free) an xtensa_insnbuf of the right size. */
|
|---|
| 90 | extern void xtensa_insnbuf_free (xtensa_insnbuf);
|
|---|
| 91 |
|
|---|
| 92 | /* Inward and outward conversion from memory images (byte streams) to our
|
|---|
| 93 | internal instruction representation. */
|
|---|
| 94 | extern void xtensa_insnbuf_to_chars (xtensa_isa, const xtensa_insnbuf,
|
|---|
| 95 | char *);
|
|---|
| 96 |
|
|---|
| 97 | extern void xtensa_insnbuf_from_chars (xtensa_isa, xtensa_insnbuf,
|
|---|
| 98 | const char *);
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 | /* ISA information. */
|
|---|
| 102 |
|
|---|
| 103 | /* Load the ISA information from a shared library. If successful, this returns
|
|---|
| 104 | a value which identifies the ISA for use in subsequent calls to the ISA
|
|---|
| 105 | library; otherwise, it returns NULL. Multiple ISAs can be loaded to support
|
|---|
| 106 | heterogeneous multiprocessor systems. */
|
|---|
| 107 | extern xtensa_isa xtensa_load_isa (libisa_module_specifier);
|
|---|
| 108 |
|
|---|
| 109 | /* Extend an existing set of ISA information by loading an additional shared
|
|---|
| 110 | library of ISA information. This is primarily intended for loading TIE
|
|---|
| 111 | extensions. If successful, the return value is non-zero. */
|
|---|
| 112 | extern int xtensa_extend_isa (xtensa_isa, libisa_module_specifier);
|
|---|
| 113 |
|
|---|
| 114 | /* The default ISA. This variable is set automatically to the ISA most
|
|---|
| 115 | recently loaded and is provided as a convenience. An exception is the GNU
|
|---|
| 116 | opcodes library, where there is a fixed interface that does not allow
|
|---|
| 117 | passing the ISA as a parameter and the ISA must be taken from this global
|
|---|
| 118 | variable. (Note: Since this variable is just a convenience, it is not
|
|---|
| 119 | exported when libisa is built as a DLL, due to the hassle of dealing with
|
|---|
|
|---|