diff --git a/libraries/GDBStub-source-level-debug/README.txt b/libraries/GDBStub-source-level-debug/README.txt new file mode 100644 index 0000000000..47ba1759d7 --- /dev/null +++ b/libraries/GDBStub-source-level-debug/README.txt @@ -0,0 +1,11 @@ +This library contains all files needed for source level debugging. +As from v2.0 of esp8266-Arduino this option was not available. + +The scope of the instruction is limited to preparing and testing a command-line gdb-debugging session. +It does not contain an instruction on how to install an IDE for the esp8266 nor the tool chain itself.   +The primary source of the tools and gdbstub-code is  http://gnutoolchains.com/download/. + +Compared to the sources supplied by VisualGDB a few modifications have been made to the sources: some IRAM-instructions have +placed to FLASH, and some assembly-functions have been alignment to 4 bytes (in order to enable the code being called via a long-call). + + diff --git a/libraries/GDBStub-source-level-debug/bin/Blink.ino b/libraries/GDBStub-source-level-debug/bin/Blink.ino new file mode 100644 index 0000000000..272dadfe00 --- /dev/null +++ b/libraries/GDBStub-source-level-debug/bin/Blink.ino @@ -0,0 +1,56 @@ + + +#include "Arduino.h" +int s_Tick=0; +int number = 0; +#define RAMFUNC __attribute__((section(".entry.text"))) + #include "gdbstub.h" + +int RAMFUNC add(int a, int b) +{ + int c; + c = a+b; + return c; +} +int RAMFUNC mult(int a, int b){ + int c; + c = a*b; + return c; +} +int RAMFUNC calculate(int a, int b, int c){ + a = add(a,b); + c = mult(a,c); + return c; +} +void RAMFUNC function(){ + int val; + //toggleIoPins(); + val = calculate(number++,2,3); + ets_printf("Tick: %d Value:%d\r\n", ++s_Tick, val); + delay(1000); +} + +void setup() { + //uart_div_modify(0, UART_CLK_FREQ / 115200); + Serial.begin(115200); + Serial.print("program started"); + gdbstub_init(); + pinMode(4, OUTPUT); // Initialize the pin as an output + pinMode(5, OUTPUT); // Initialize the pin as an output +} + +void RAMFUNC toggleIoPins() { + digitalWrite(4, LOW); + digitalWrite(5, LOW); + delay(100); + digitalWrite(4, HIGH); + digitalWrite(5, HIGH); + delay(200); +} +int loopCount=0; +// the loop function runs over and over again forever +void RAMFUNC loop() { + loopCount++; + function(); + ets_printf("Loopcount: %d",loopCount); +} diff --git a/libraries/GDBStub-source-level-debug/bin/Blink.ino.elf b/libraries/GDBStub-source-level-debug/bin/Blink.ino.elf new file mode 100644 index 0000000000..68d905c967 Binary files /dev/null and b/libraries/GDBStub-source-level-debug/bin/Blink.ino.elf differ diff --git a/libraries/GDBStub-source-level-debug/bin/gdbcmds b/libraries/GDBStub-source-level-debug/bin/gdbcmds new file mode 100644 index 0000000000..5c9382fb52 --- /dev/null +++ b/libraries/GDBStub-source-level-debug/bin/gdbcmds @@ -0,0 +1,5 @@ +set remote hardware-breakpoint-limit 1 +set remote hardware-watchpoint-limit 1 +set debug xtensa 4 +target remote \\.\COM9 +thb loop \ No newline at end of file diff --git a/libraries/GDBStub-source-level-debug/bin/xtensa-lx106-elf-gdb.exe b/libraries/GDBStub-source-level-debug/bin/xtensa-lx106-elf-gdb.exe new file mode 100644 index 0000000000..2d567fde8c Binary files /dev/null and b/libraries/GDBStub-source-level-debug/bin/xtensa-lx106-elf-gdb.exe differ diff --git a/libraries/GDBStub-source-level-debug/gdbcmds b/libraries/GDBStub-source-level-debug/gdbcmds new file mode 100644 index 0000000000..668c616b40 --- /dev/null +++ b/libraries/GDBStub-source-level-debug/gdbcmds @@ -0,0 +1,5 @@ +set remote hardware-breakpoint-limit 1 +set remote hardware-watchpoint-limit 1 +set debug xtensa 4 +target remote \\.\COM9 +thb loop diff --git a/libraries/GDBStub-source-level-debug/gdbstub-breakpoint1.png b/libraries/GDBStub-source-level-debug/gdbstub-breakpoint1.png new file mode 100644 index 0000000000..7527764103 Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-breakpoint1.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstub-comport-output.png b/libraries/GDBStub-source-level-debug/gdbstub-comport-output.png new file mode 100644 index 0000000000..8cc7cb21e4 Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-comport-output.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstub-dir.png b/libraries/GDBStub-source-level-debug/gdbstub-dir.png new file mode 100644 index 0000000000..6b4640b254 Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-dir.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstub-info-break.png b/libraries/GDBStub-source-level-debug/gdbstub-info-break.png new file mode 100644 index 0000000000..be993ad94b Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-info-break.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstub-lib.png b/libraries/GDBStub-source-level-debug/gdbstub-lib.png new file mode 100644 index 0000000000..73e9cf37c5 Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-lib.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstub-optimizer.png b/libraries/GDBStub-source-level-debug/gdbstub-optimizer.png new file mode 100644 index 0000000000..a7e882b44e Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-optimizer.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstub-start.png b/libraries/GDBStub-source-level-debug/gdbstub-start.png new file mode 100644 index 0000000000..6302aea987 Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-start.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstub-thb-loop.png b/libraries/GDBStub-source-level-debug/gdbstub-thb-loop.png new file mode 100644 index 0000000000..00ea4bcd04 Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-thb-loop.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstub-thb-loop2.png b/libraries/GDBStub-source-level-debug/gdbstub-thb-loop2.png new file mode 100644 index 0000000000..be993ad94b Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-thb-loop2.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstub-watchpoint-setcondition-reached.png b/libraries/GDBStub-source-level-debug/gdbstub-watchpoint-setcondition-reached.png new file mode 100644 index 0000000000..79f838befa Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-watchpoint-setcondition-reached.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstub-watchpoint-setcondition.png b/libraries/GDBStub-source-level-debug/gdbstub-watchpoint-setcondition.png new file mode 100644 index 0000000000..7baa352594 Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstub-watchpoint-setcondition.png differ diff --git a/libraries/GDBStub-source-level-debug/gdbstuff.png b/libraries/GDBStub-source-level-debug/gdbstuff.png new file mode 100644 index 0000000000..13ec68a67d Binary files /dev/null and b/libraries/GDBStub-source-level-debug/gdbstuff.png differ diff --git a/libraries/GDBStub-source-level-debug/instructions.rst b/libraries/GDBStub-source-level-debug/instructions.rst new file mode 100644 index 0000000000..01de5c3dfd --- /dev/null +++ b/libraries/GDBStub-source-level-debug/instructions.rst @@ -0,0 +1,166 @@ +**Instructions command line debugging ESP8266** + ++----+----------------+------------------------------------------------------------------------+-----------+--------+-------------+ +| | Author | Fred Kuijper | Version | 0.1 | 25-1-2018 | ++====+================+========================================================================+===========+========+=============+ +| | | Translation to English | Version | 0.2 | 1-02-2018 | ++----+----------------+------------------------------------------------------------------------+-----------+--------+-------------+ +| | | Minor modifications | Version | 0.21 | 4-2-2018 | ++----+----------------+------------------------------------------------------------------------+-----------+--------+-------------+ + +Status: under construction! + +Scope +====== +The scope is limited to preparing and testing a command-line gdb-debugging session for the esp8266 processor. It does not contain an instruction on how to install an IDE for the esp8266 nor the tool chain itself. +The instruction is based on a Windows-environment. The primary source of the tools and gdbstub-code is http://gnutoolchains.com/download/. +A few modifications have been made to the sources: some IRAM-instructions have placed to FLASH, and some assembly-functions have been alignment to 4 bytes (in order to enable the code being called via +a long-call). + +Command line debugging +====================== +The next steps should be followed to start command line debugging. +1: Download the files from github. +*The directory should look like this:* + +.. figure:: gdbstub-lib.png + +Directory “\ *bin*\ ” contains all the files necessary to execute a +command line debug-session.: + +.. figure:: gdbstub-dir.png +Copy the files of directory “\ *bin”* to a location of your choice. +Copy the library in directory “\ *gdbstub*\ ” to a location where you normally put your libraries. +**Mind you**: The original files from *VisualGDB* have been modified in order to reduce the IRAM-usage, and also have set the some #defines in file *gdbstub-cfg.h*. + +2: Prepare your own sketch or use the example-sketch provided by the repository. In case you use your own sketch, the following lines have to be added. + + 1.Add #include "gdbstub.h" + + 2.Add to function setup(): + Serial.begin(115200); + + gdbstub_init(); + +**Mind you**: After this **Serial.printf()** doesn’t work anymore as +gdbstub\_init() takes over the UART-interrupt, instead use function +**ets\_printf** for output of messages! + +4: Build the example app using compiler/linker options: “-\ *ggdb –Og +–mlongcalls*\ ”. +https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#Debugging-Options. +After a new build, be sure to copy the latest application elf-file to +the directory where the bin-files reside. +The Arduino\_IDE compiler/linker compiles with options: “\ *-Os -g +–mlongcalls”* (*I do not know how and where to set these options*) , for +“Eclipse-Sloeber “ set the options to “–\ *ggdb –Og –mlongcalls*\ ” , +*“–Og”* generates easier to debug code (see +`*https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html* `__ +*). * + +5: File “\ *gdbcmds”* is the configuration-file containing the arguments for starting the debug-session: + 1.set remote hardware-breakpoint-limit 1 + + 2.set remote hardware-watchpoint-limit 1 + + 3.set debug xtensa 4 + + 4.target remote `\\\\.\\COM9 `__ (**change to your own com-port**) + + 5.file blink.ino.elf (**the application of choice, add complete path if elf-file resides somewhere else**) + + 6.thb loop (or any location you want your program to start the debug-session). + +6: Open a command shell and go to the working directory where *the files +xtensa-lx106-elf-gdb* and *gdbcmds* reside. Copy the latest ELF-file to +this directory. + +7: Then download the application and verify that the debug-stub is actually +present and has started: + +.. figure:: gdbstub-start.png + +You should see: **“$ST05#b9”** on the debug-port of the esp8266. + +8: Then execute command: “\ *xtensa-lx106-elf-gdb.exe -x gdbcmds*\ ”. If +everything goes well the application will start and stop at location +“\ *loop*\ ”. +Output on the debug-port: + +.. figure:: gdbstub-comport-output.png + +Output from the target: + +.. figure:: gdbstub-breakpoint1.png + +Then execute command “\ *info break*\ ”: + +.. figure:: gdbstub-info-break.png +And the breakpoints defined in file *gdbcmds* are shown. + +9: Continue the program by entering “\ *continue*\ ” + +.. figure:: gdbstub-thb-loop.png +After 1000 milliseconds the program will stop at function “\ *loop*\ ”. + +*Add a watchpoint* +1: Define a *watchpoint* and an *expression* +2: Continue executing and wait. +*Condition reached* + +For more extensive info about *command-line gdb* I refer to +http://sourceware.org/gdb/onlinedocs/gdb/index.html#SEC_Contents + +This was it! I hope this may inspire you to use source level +debugging. I personally prefer and would recommend using Eclipse-Sloeber +as IDE. + +Issues, tips and tricks +======================= + +1. Put the code to be debugged preferably in IRAM, you can then put + multiple breakpoints in a function (the esp8266 has only one hardware + breakpoint). + +2. Since esp8266 has only 1 hardware-breakpoint, it is useful to define a + so-called hardware temporary breakpoint (*thb*). *thb* or *hb* + can also be used to set a breakpoint in Flash code. A temporary + breakpoint is deactivated after each hit, so a next hardware + breakpoint may be set. + +3. Always check whether the target actually contains *gdbstub*. Start a + terminal program (for example *RealTerm*), connect with the com port, + reset the target. If all goes well, a message from *gdbstub* will + appear on the screen: **“$T05#B9**\ ”. If not, the application is not + properly built. + +4. Sometimes the debugger doesn’t stop at a certain location: this may + be caused by the compiler’s optimizer, the optimizer could generate + inline code (see the function calculate () as shown below)! To + minimize these effects compile with flag “–Og” . + +.. figure:: gdbstub-watchpoint-setcondition-reached.png + +5. Function **ets\_printf()** and **Serial.printf()** behave + differently. The serial-IO for the Arduino-IDE is based on *class + Serial* , the debugger uses the standard-IO library... + + **Serial.prinf()** is disabled by *gdbstub*, so use **ets\_printf()** + instead. + +References +========== + +1. https://github.com/espressif/esp-gdbstub + +2. https://github.com/esp8266/Arduino/tree/master/libraries/GDBStub/ + +3. https://espressif.com/sites/default/files/documentation/esp8266_reset_causes_and_common_fatal_exception_causes_en.pdf + +4. https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html + +5. http://sourceware.org/gdb/onlinedocs/gdb/index.html#SEC_Contents + +6. https://visualgdb.com/tutorials/esp8266/gdbstub/ + +7. http://gnutoolchains.com/download/ diff --git a/libraries/GDBStub-source-level-debug/library.properties b/libraries/GDBStub-source-level-debug/library.properties new file mode 100644 index 0000000000..649e1e01c8 --- /dev/null +++ b/libraries/GDBStub-source-level-debug/library.properties @@ -0,0 +1,9 @@ +name=GDBStub +version=0 +author=ESPRESSIF/VisualGDB +maintainer=Fred Kuijper +sentence=GDB server stub by Espressif/VisualGDB +paragraph=GDB server stub helps debug source level debug via the serial port. +category=Uncategorized +url=https://github.com/espressif/esp-gdbstub +architectures=esp8266 diff --git a/libraries/GDBStub-source-level-debug/src/License b/libraries/GDBStub-source-level-debug/src/License new file mode 100644 index 0000000000..a0f05cbad0 --- /dev/null +++ b/libraries/GDBStub-source-level-debug/src/License @@ -0,0 +1,24 @@ +ESPRESSIF MIT License + +Copyright (c) 2015 + +Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case, it is free of charge, to any person obtaining a copy of this software and associated documentation files (the ��Software��), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED ��AS IS��, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +���� MIT ����֤ + +��Ȩ (c) 2015 <������Ϣ�Ƽ����Ϻ������޹�˾> + +������֤��Ȩ������������Ϣ�Ƽ� ESP8266 ��Ʒ��Ӧ�ÿ������ڴ�����£�������֤�����Ȩ�κλ�ø�������������ĵ���ͳ��Ϊ�������������������Ƶؾ�Ӫ�����������������Ƶ�ʹ�á����ơ��޸ġ��ϲ������淢�С�ɢ��������Ȩ������������������������Ȩ��������Ȩ����������ЩȨ����ͬʱ������������������ + +�����������������и����ж�����������ϵİ�Ȩ��������Ȩ������ + +�������������������ṩ��û���κ���ȷ�򰵺��ĵ������������������ڹ��������ԡ��ʺ�ijһ�ض���;�ͷ���Ȩ�ı�֤�����ߺͰ�Ȩ���������κ�����¾�����������������ʹ��������Ժ�ͬ��ʽ��������Ȩ��������ʽ������κ����⡢�𺦻��������θ��� + + + + diff --git a/libraries/GDBStub-source-level-debug/src/README.md b/libraries/GDBStub-source-level-debug/src/README.md new file mode 100644 index 0000000000..c09ac67f2f --- /dev/null +++ b/libraries/GDBStub-source-level-debug/src/README.md @@ -0,0 +1,69 @@ + +GDBSTUB +======= + +Intro +----- + +While the ESP8266 supports the standard Gnu set of C programming utilities, for now the choice of debuggers +has been limited: there is an attempt at [OpenOCD support](https://github.com/projectgus/openocd), but at +the time of writing, it doesn't support hardware watchpoints and breakpoints yet, and it needs a separate +JTAG adapter connecting to the ESP8266s JTAG pins. As an alternative, [Cesanta](https://www.cesanta.com/) +has implemented a barebones[GDB stub](https://blog.cesanta.com/esp8266-gdb) in their Smart.js solution - +unfortunately, this only supports exception catching and needs some work before you can use it outside of +the Smart.js platform. Moreover, it also does not work with FreeRTOS. + +For internal use, we at Espressif desired a GDB stub that works with FreeRTOS and is a bit more capable, +so we designed our own implementation of it. This stub works both under FreeRTOS as well as the OS-less +SDK and is able to catch exceptions and do backtraces on them, read and write memory, forward [os_]printf +statements to gdb, single-step instructions and set hardware break- and watchpoints. It connects to the +host machine (which runs gdb) using the standard serial connection that's also used for programming. + +In order to be useful the gdbstub has to be used in conjunction with an xtensa-lx106-elf-gdb, for example +as generated by the [esp-open-sdk](https://github.com/pfalcon/esp-open-sdk) project. + +Usage +----- + * Grab the gdbstub project and put the files in a directory called 'gdbstub' in your project. You can do this +either by checking out the Git repo, or adding the Git repo as a submodule to your project if it's already +in Git. + * Modify your Makefile. You'll need to include the gdbstub sources: if your Makefile is structured like the +ones in the Espressif examples, you can add `gdbstub` to the `SUBDIRS` define and `gdbstub/libgdbstub.a` to the +`COMPONENTS_eagle.app.v6` define. Also, you probably want to add `-ggdb` to your compiler flags (`TARGET_LDFLAGS`) +and, if you are debugging, change any optimation flags (-Os, -O2 etc) into `-Og`. Finally, make sure your Makefile +also compiles .S files. + * Configure gdbstub by editting `gdbstub-cfg.h`. There are a bunch of options you can tweak: FreeRTOS or bare SDK, +private exception/breakpoint stack, console redirection to GDB, wait till debugger attachment etc. You can also +configure the options by including the proper -Dwhatever gcc flags in your Makefiles. + * In your user_main.c, add an `#include <../gdbstub/gdbstub.h>` and call `gdbstub_init();` somewhere in user_main. + * Compile and flash your board. + * Run gdb, depending on your configuration immediately after resetting the board or after it has run into +an exception. The easiest way to do it is to use the provided script: xtensa-lx106-elf-gdb -x gdbcmds -b 38400 +Change the '38400' into the baud rate your code uses. You may need to change the gdbcmds script to fit the +configuration of your hardware and build environment. + +Notes +----- + * Using software breakpoints ('br') only works on code that's in RAM. Code in flash can only have a hardware +breakpoint ('hbr'). + * Due to hardware limitations, only one hardware breakpount and one hardware watchpoint are available. + * Pressing control-C to interrupt the running program depends on gdbstub hooking the UART interrupt. +If some code re-hooks this afterwards, gdbstub won't be able to receive characters. If gdbstub handles +the interrupt, the user code will not receive any characters. + * Continuing from an exception is not (yet) supported in FreeRTOS mode. + * The WiFi hardware is designed to be serviced by software periodically. It has some buffers so it +will behave OK when some data comes in while the processor is busy, but these buffers are not infinite. +If the WiFi hardware receives lots of data while the debugger has stopped the CPU, it is bound +to crash. This will happen mostly when working with UDP and/or ICMP; TCP-connections in general will +not send much more data when the other side doesn't send any ACKs. + +License +------- +This gdbstub is licensed under the Espressif MIT license, as described in the License file. + + +Thanks +------ + * Cesanta, for their initial ESP8266 exception handling only gdbstub, + * jcmvbkbc, for providing an incompatible but interesting gdbstub for other Xtensa CPUs, + * Sysprogs (makers of VisualGDB), for their suggestions and bugreports. diff --git a/libraries/GDBStub-source-level-debug/src/core-isa.h b/libraries/GDBStub-source-level-debug/src/core-isa.h new file mode 100644 index 0000000000..612fbf8400 --- /dev/null +++ b/libraries/GDBStub-source-level-debug/src/core-isa.h @@ -0,0 +1,459 @@ +/* + * xtensa/config/core-isa.h -- HAL definitions that are dependent on Xtensa + * processor CORE configuration + * + * See , which includes this file, for more details. + */ + +/* Xtensa processor core configuration information. + + Copyright (c) 1999-2010 Tensilica Inc. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#ifndef _XTENSA_CORE_CONFIGURATION_H +#define _XTENSA_CORE_CONFIGURATION_H + + +/**************************************************************************** + Parameters Useful for Any Code, USER or PRIVILEGED + ****************************************************************************/ + +/* + * Note: Macros of the form XCHAL_HAVE_*** have a value of 1 if the option is + * configured, and a value of 0 otherwise. These macros are always defined. + */ + + +/*---------------------------------------------------------------------- + ISA + ----------------------------------------------------------------------*/ + +#define XCHAL_HAVE_BE 0 /* big-endian byte ordering */ +#define XCHAL_HAVE_WINDOWED 0 /* windowed registers option */ +#define XCHAL_NUM_AREGS 16 /* num of physical addr regs */ +#define XCHAL_NUM_AREGS_LOG2 4 /* log2(XCHAL_NUM_AREGS) */ +#define XCHAL_MAX_INSTRUCTION_SIZE 3 /* max instr bytes (3..8) */ +#define XCHAL_HAVE_DEBUG 1 /* debug option */ +#define XCHAL_HAVE_DENSITY 1 /* 16-bit instructions */ +#define XCHAL_HAVE_LOOPS 0 /* zero-overhead loops */ +#define XCHAL_HAVE_NSA 1 /* NSA/NSAU instructions */ +#define XCHAL_HAVE_MINMAX 0 /* MIN/MAX instructions */ +#define XCHAL_HAVE_SEXT 0 /* SEXT instruction */ +#define XCHAL_HAVE_CLAMPS 0 /* CLAMPS instruction */ +#define XCHAL_HAVE_MUL16 1 /* MUL16S/MUL16U instructions */ +#define XCHAL_HAVE_MUL32 1 /* MULL instruction */ +#define XCHAL_HAVE_MUL32_HIGH 0 /* MULUH/MULSH instructions */ +#define XCHAL_HAVE_DIV32 0 /* QUOS/QUOU/REMS/REMU instructions */ +#define XCHAL_HAVE_L32R 1 /* L32R instruction */ +#define XCHAL_HAVE_ABSOLUTE_LITERALS 1 /* non-PC-rel (extended) L32R */ +#define XCHAL_HAVE_CONST16 0 /* CONST16 instruction */ +#define XCHAL_HAVE_ADDX 1 /* ADDX#/SUBX# instructions */ +#define XCHAL_HAVE_WIDE_BRANCHES 0 /* B*.W18 or B*.W15 instr's */ +#define XCHAL_HAVE_PREDICTED_BRANCHES 0 /* B[EQ/EQZ/NE/NEZ]T instr's */ +#define XCHAL_HAVE_CALL4AND12 0 /* (obsolete option) */ +#define XCHAL_HAVE_ABS 1 /* ABS instruction */ +/*#define XCHAL_HAVE_POPC 0*/ /* POPC instruction */ +/*#define XCHAL_HAVE_CRC 0*/ /* CRC instruction */ +#define XCHAL_HAVE_RELEASE_SYNC 0 /* L32AI/S32RI instructions */ +#define XCHAL_HAVE_S32C1I 0 /* S32C1I instruction */ +#define XCHAL_HAVE_SPECULATION 0 /* speculation */ +#define XCHAL_HAVE_FULL_RESET 1 /* all regs/state reset */ +#define XCHAL_NUM_CONTEXTS 1 /* */ +#define XCHAL_NUM_MISC_REGS 0 /* num of scratch regs (0..4) */ +#define XCHAL_HAVE_TAP_MASTER 0 /* JTAG TAP control instr's */ +#define XCHAL_HAVE_PRID 1 /* processor ID register */ +#define XCHAL_HAVE_EXTERN_REGS 1 /* WER/RER instructions */ +#define XCHAL_HAVE_MP_INTERRUPTS 0 /* interrupt distributor port */ +#define XCHAL_HAVE_MP_RUNSTALL 0 /* core RunStall control port */ +#define XCHAL_HAVE_THREADPTR 0 /* THREADPTR register */ +#define XCHAL_HAVE_BOOLEANS 0 /* boolean registers */ +#define XCHAL_HAVE_CP 0 /* CPENABLE reg (coprocessor) */ +#define XCHAL_CP_MAXCFG 0 /* max allowed cp id plus one */ +#define XCHAL_HAVE_MAC16 0 /* MAC16 package */ +#define XCHAL_HAVE_VECTORFPU2005 0 /* vector floating-point pkg */ +#define XCHAL_HAVE_FP 0 /* floating point pkg */ +#define XCHAL_HAVE_DFP 0 /* double precision FP pkg */ +#define XCHAL_HAVE_DFP_accel 0 /* double precision FP acceleration pkg */ +#define XCHAL_HAVE_VECTRA1 0 /* Vectra I pkg */ +#define XCHAL_HAVE_VECTRALX 0 /* Vectra LX pkg */ +#define XCHAL_HAVE_HIFIPRO 0 /* HiFiPro Audio Engine pkg */ +#define XCHAL_HAVE_HIFI2 0 /* HiFi2 Audio Engine pkg */ +#define XCHAL_HAVE_CONNXD2 0 /* ConnX D2 pkg */ + + +/*---------------------------------------------------------------------- + MISC + ----------------------------------------------------------------------*/ + +#define XCHAL_NUM_WRITEBUFFER_ENTRIES 1 /* size of write buffer */ +#define XCHAL_INST_FETCH_WIDTH 4 /* instr-fetch width in bytes */ +#define XCHAL_DATA_WIDTH 4 /* data width in bytes */ +/* In T1050, applies to selected core load and store instructions (see ISA): */ +#define XCHAL_UNALIGNED_LOAD_EXCEPTION 1 /* unaligned loads cause exc. */ +#define XCHAL_UNALIGNED_STORE_EXCEPTION 1 /* unaligned stores cause exc.*/ +#define XCHAL_UNALIGNED_LOAD_HW 0 /* unaligned loads work in hw */ +#define XCHAL_UNALIGNED_STORE_HW 0 /* unaligned stores work in hw*/ + +#define XCHAL_SW_VERSION 800001 /* sw version of this header */ + +#define XCHAL_CORE_ID "lx106" /* alphanum core name + (CoreID) set in the Xtensa + Processor Generator */ + +#define XCHAL_BUILD_UNIQUE_ID 0x0002B6F6 /* 22-bit sw build ID */ + +/* + * These definitions describe the hardware targeted by this software. + */ +#define XCHAL_HW_CONFIGID0 0xC28CDAFA /* ConfigID hi 32 bits*/ +#define XCHAL_HW_CONFIGID1 0x1082B6F6 /* ConfigID lo 32 bits*/ +#define XCHAL_HW_VERSION_NAME "LX3.0.1" /* full version name */ +#define XCHAL_HW_VERSION_MAJOR 2300 /* major ver# of targeted hw */ +#define XCHAL_HW_VERSION_MINOR 1 /* minor ver# of targeted hw */ +#define XCHAL_HW_VERSION 230001 /* major*100+minor */ +#define XCHAL_HW_REL_LX3 1 +#define XCHAL_HW_REL_LX3_0 1 +#define XCHAL_HW_REL_LX3_0_1 1 +#define XCHAL_HW_CONFIGID_RELIABLE 1 +/* If software targets a *range* of hardware versions, these are the bounds: */ +#define XCHAL_HW_MIN_VERSION_MAJOR 2300 /* major v of earliest tgt hw */ +#define XCHAL_HW_MIN_VERSION_MINOR 1 /* minor v of earliest tgt hw */ +#define XCHAL_HW_MIN_VERSION 230001 /* earliest targeted hw */ +#define XCHAL_HW_MAX_VERSION_MAJOR 2300 /* major v of latest tgt hw */ +#define XCHAL_HW_MAX_VERSION_MINOR 1 /* minor v of latest tgt hw */ +#define XCHAL_HW_MAX_VERSION 230001 /* latest targeted hw */ + + +/*---------------------------------------------------------------------- + CACHE + ----------------------------------------------------------------------*/ + +#define XCHAL_ICACHE_LINESIZE 4 /* I-cache line size in bytes */ +#define XCHAL_DCACHE_LINESIZE 4 /* D-cache line size in bytes */ +#define XCHAL_ICACHE_LINEWIDTH 2 /* log2(I line size in bytes) */ +#define XCHAL_DCACHE_LINEWIDTH 2 /* log2(D line size in bytes) */ + +#define XCHAL_ICACHE_SIZE 0 /* I-cache size in bytes or 0 */ +#define XCHAL_DCACHE_SIZE 0 /* D-cache size in bytes or 0 */ + +#define XCHAL_DCACHE_IS_WRITEBACK 0 /* writeback feature */ +#define XCHAL_DCACHE_IS_COHERENT 0 /* MP coherence feature */ + +#define XCHAL_HAVE_PREFETCH 0 /* PREFCTL register */ + + + + +/**************************************************************************** + Parameters Useful for PRIVILEGED (Supervisory or Non-Virtualized) Code + ****************************************************************************/ + + +#ifndef XTENSA_HAL_NON_PRIVILEGED_ONLY + +/*---------------------------------------------------------------------- + CACHE + ----------------------------------------------------------------------*/ + +#define XCHAL_HAVE_PIF 1 /* any outbound PIF present */ + +/* If present, cache size in bytes == (ways * 2^(linewidth + setwidth)). */ + +/* Number of cache sets in log2(lines per way): */ +#define XCHAL_ICACHE_SETWIDTH 0 +#define XCHAL_DCACHE_SETWIDTH 0 + +/* Cache set associativity (number of ways): */ +#define XCHAL_ICACHE_WAYS 1 +#define XCHAL_DCACHE_WAYS 1 + +/* Cache features: */ +#define XCHAL_ICACHE_LINE_LOCKABLE 0 +#define XCHAL_DCACHE_LINE_LOCKABLE 0 +#define XCHAL_ICACHE_ECC_PARITY 0 +#define XCHAL_DCACHE_ECC_PARITY 0 + +/* Cache access size in bytes (affects operation of SICW instruction): */ +#define XCHAL_ICACHE_ACCESS_SIZE 1 +#define XCHAL_DCACHE_ACCESS_SIZE 1 + +/* Number of encoded cache attr bits (see for decoded bits): */ +#define XCHAL_CA_BITS 4 + + +/*---------------------------------------------------------------------- + INTERNAL I/D RAM/ROMs and XLMI + ----------------------------------------------------------------------*/ + +#define XCHAL_NUM_INSTROM 1 /* number of core instr. ROMs */ +#define XCHAL_NUM_INSTRAM 2 /* number of core instr. RAMs */ +#define XCHAL_NUM_DATAROM 1 /* number of core data ROMs */ +#define XCHAL_NUM_DATARAM 2 /* number of core data RAMs */ +#define XCHAL_NUM_URAM 0 /* number of core unified RAMs*/ +#define XCHAL_NUM_XLMI 1 /* number of core XLMI ports */ + +/* Instruction ROM 0: */ +#define XCHAL_INSTROM0_VADDR 0x40200000 +#define XCHAL_INSTROM0_PADDR 0x40200000 +#define XCHAL_INSTROM0_SIZE 1048576 +#define XCHAL_INSTROM0_ECC_PARITY 0 + +/* Instruction RAM 0: */ +#define XCHAL_INSTRAM0_VADDR 0x40000000 +#define XCHAL_INSTRAM0_PADDR 0x40000000 +#define XCHAL_INSTRAM0_SIZE 1048576 +#define XCHAL_INSTRAM0_ECC_PARITY 0 + +/* Instruction RAM 1: */ +#define XCHAL_INSTRAM1_VADDR 0x40100000 +#define XCHAL_INSTRAM1_PADDR 0x40100000 +#define XCHAL_INSTRAM1_SIZE 1048576 +#define XCHAL_INSTRAM1_ECC_PARITY 0 + +/* Data ROM 0: */ +#define XCHAL_DATAROM0_VADDR 0x3FF40000 +#define XCHAL_DATAROM0_PADDR 0x3FF40000 +#define XCHAL_DATAROM0_SIZE 262144 +#define XCHAL_DATAROM0_ECC_PARITY 0 + +/* Data RAM 0: */ +#define XCHAL_DATARAM0_VADDR 0x3FFC0000 +#define XCHAL_DATARAM0_PADDR 0x3FFC0000 +#define XCHAL_DATARAM0_SIZE 262144 +#define XCHAL_DATARAM0_ECC_PARITY 0 + +/* Data RAM 1: */ +#define XCHAL_DATARAM1_VADDR 0x3FF80000 +#define XCHAL_DATARAM1_PADDR 0x3FF80000 +#define XCHAL_DATARAM1_SIZE 262144 +#define XCHAL_DATARAM1_ECC_PARITY 0 + +/* XLMI Port 0: */ +#define XCHAL_XLMI0_VADDR 0x3FF00000 +#define XCHAL_XLMI0_PADDR 0x3FF00000 +#define XCHAL_XLMI0_SIZE 262144 +#define XCHAL_XLMI0_ECC_PARITY 0 + + +/*---------------------------------------------------------------------- + INTERRUPTS and TIMERS + ----------------------------------------------------------------------*/ + +#define XCHAL_HAVE_INTERRUPTS 1 /* interrupt option */ +#define XCHAL_HAVE_HIGHPRI_INTERRUPTS 1 /* med/high-pri. interrupts */ +#define XCHAL_HAVE_NMI 1 /* non-maskable interrupt */ +#define XCHAL_HAVE_CCOUNT 1 /* CCOUNT reg. (timer option) */ +#define XCHAL_NUM_TIMERS 1 /* number of CCOMPAREn regs */ +#define XCHAL_NUM_INTERRUPTS 15 /* number of interrupts */ +#define XCHAL_NUM_INTERRUPTS_LOG2 4 /* ceil(log2(NUM_INTERRUPTS)) */ +#define XCHAL_NUM_EXTINTERRUPTS 13 /* num of external interrupts */ +#define XCHAL_NUM_INTLEVELS 2 /* number of interrupt levels + (not including level zero) */ +#define XCHAL_EXCM_LEVEL 1 /* level masked by PS.EXCM */ + /* (always 1 in XEA1; levels 2 .. EXCM_LEVEL are "medium priority") */ + +/* Masks of interrupts at each interrupt level: */ +#define XCHAL_INTLEVEL1_MASK 0x00003FFF +#define XCHAL_INTLEVEL2_MASK 0x00000000 +#define XCHAL_INTLEVEL3_MASK 0x00004000 +#define XCHAL_INTLEVEL4_MASK 0x00000000 +#define XCHAL_INTLEVEL5_MASK 0x00000000 +#define XCHAL_INTLEVEL6_MASK 0x00000000 +#define XCHAL_INTLEVEL7_MASK 0x00000000 + +/* Masks of interrupts at each range 1..n of interrupt levels: */ +#define XCHAL_INTLEVEL1_ANDBELOW_MASK 0x00003FFF +#define XCHAL_INTLEVEL2_ANDBELOW_MASK 0x00003FFF +#define XCHAL_INTLEVEL3_ANDBELOW_MASK 0x00007FFF +#define XCHAL_INTLEVEL4_ANDBELOW_MASK 0x00007FFF +#define XCHAL_INTLEVEL5_ANDBELOW_MASK 0x00007FFF +#define XCHAL_INTLEVEL6_ANDBELOW_MASK 0x00007FFF +#define XCHAL_INTLEVEL7_ANDBELOW_MASK 0x00007FFF + +/* Level of each interrupt: */ +#define XCHAL_INT0_LEVEL 1 +#define XCHAL_INT1_LEVEL 1 +#define XCHAL_INT2_LEVEL 1 +#define XCHAL_INT3_LEVEL 1 +#define XCHAL_INT4_LEVEL 1 +#define XCHAL_INT5_LEVEL 1 +#define XCHAL_INT6_LEVEL 1 +#define XCHAL_INT7_LEVEL 1 +#define XCHAL_INT8_LEVEL 1 +#define XCHAL_INT9_LEVEL 1 +#define XCHAL_INT10_LEVEL 1 +#define XCHAL_INT11_LEVEL 1 +#define XCHAL_INT12_LEVEL 1 +#define XCHAL_INT13_LEVEL 1 +#define XCHAL_INT14_LEVEL 3 +#define XCHAL_DEBUGLEVEL 2 /* debug interrupt level */ +#define XCHAL_HAVE_DEBUG_EXTERN_INT 1 /* OCD external db interrupt */ +#define XCHAL_NMILEVEL 3 /* NMI "level" (for use with + EXCSAVE/EPS/EPC_n, RFI n) */ + +/* Type of each interrupt: */ +#define XCHAL_INT0_TYPE XTHAL_INTTYPE_EXTERN_LEVEL +#define XCHAL_INT1_TYPE XTHAL_INTTYPE_EXTERN_LEVEL +#define XCHAL_INT2_TYPE XTHAL_INTTYPE_EXTERN_LEVEL +#define XCHAL_INT3_TYPE XTHAL_INTTYPE_EXTERN_LEVEL +#define XCHAL_INT4_TYPE XTHAL_INTTYPE_EXTERN_LEVEL +#define XCHAL_INT5_TYPE XTHAL_INTTYPE_EXTERN_LEVEL +#define XCHAL_INT6_TYPE XTHAL_INTTYPE_TIMER +#define XCHAL_INT7_TYPE XTHAL_INTTYPE_SOFTWARE +#define XCHAL_INT8_TYPE XTHAL_INTTYPE_EXTERN_EDGE +#define XCHAL_INT9_TYPE XTHAL_INTTYPE_EXTERN_EDGE +#define XCHAL_INT10_TYPE XTHAL_INTTYPE_EXTERN_EDGE +#define XCHAL_INT11_TYPE XTHAL_INTTYPE_EXTERN_EDGE +#define XCHAL_INT12_TYPE XTHAL_INTTYPE_EXTERN_EDGE +#define XCHAL_INT13_TYPE XTHAL_INTTYPE_EXTERN_EDGE +#define XCHAL_INT14_TYPE XTHAL_INTTYPE_NMI + +/* Masks of interrupts for each type of interrupt: */ +#define XCHAL_INTTYPE_MASK_UNCONFIGURED 0xFFFF8000 +#define XCHAL_INTTYPE_MASK_SOFTWARE 0x00000080 +#define XCHAL_INTTYPE_MASK_EXTERN_EDGE 0x00003F00 +#define XCHAL_INTTYPE_MASK_EXTERN_LEVEL 0x0000003F +#define XCHAL_INTTYPE_MASK_TIMER 0x00000040 +#define XCHAL_INTTYPE_MASK_NMI 0x00004000 +#define XCHAL_INTTYPE_MASK_WRITE_ERROR 0x00000000 + +/* Interrupt numbers assigned to specific interrupt sources: */ +#define XCHAL_TIMER0_INTERRUPT 6 /* CCOMPARE0 */ +#define XCHAL_TIMER1_INTERRUPT XTHAL_TIMER_UNCONFIGURED +#define XCHAL_TIMER2_INTERRUPT XTHAL_TIMER_UNCONFIGURED +#define XCHAL_TIMER3_INTERRUPT XTHAL_TIMER_UNCONFIGURED +#define XCHAL_NMI_INTERRUPT 14 /* non-maskable interrupt */ + +/* Interrupt numbers for levels at which only one interrupt is configured: */ +#define XCHAL_INTLEVEL3_NUM 14 +/* (There are many interrupts each at level(s) 1.) */ + + +/* + * External interrupt vectors/levels. + * These macros describe how Xtensa processor interrupt numbers + * (as numbered internally, eg. in INTERRUPT and INTENABLE registers) + * map to external BInterrupt pins, for those interrupts + * configured as external (level-triggered, edge-triggered, or NMI). + * See the Xtensa processor databook for more details. + */ + +/* Core interrupt numbers mapped to each EXTERNAL interrupt number: */ +#define XCHAL_EXTINT0_NUM 0 /* (intlevel 1) */ +#define XCHAL_EXTINT1_NUM 1 /* (intlevel 1) */ +#define XCHAL_EXTINT2_NUM 2 /* (intlevel 1) */ +#define XCHAL_EXTINT3_NUM 3 /* (intlevel 1) */ +#define XCHAL_EXTINT4_NUM 4 /* (intlevel 1) */ +#define XCHAL_EXTINT5_NUM 5 /* (intlevel 1) */ +#define XCHAL_EXTINT6_NUM 8 /* (intlevel 1) */ +#define XCHAL_EXTINT7_NUM 9 /* (intlevel 1) */ +#define XCHAL_EXTINT8_NUM 10 /* (intlevel 1) */ +#define XCHAL_EXTINT9_NUM 11 /* (intlevel 1) */ +#define XCHAL_EXTINT10_NUM 12 /* (intlevel 1) */ +#define XCHAL_EXTINT11_NUM 13 /* (intlevel 1) */ +#define XCHAL_EXTINT12_NUM 14 /* (intlevel 3) */ + + +/*---------------------------------------------------------------------- + EXCEPTIONS and VECTORS + ----------------------------------------------------------------------*/ + +#define XCHAL_XEA_VERSION 2 /* Xtensa Exception Architecture + number: 1 == XEA1 (old) + 2 == XEA2 (new) + 0 == XEAX (extern) */ +#define XCHAL_HAVE_XEA1 0 /* Exception Architecture 1 */ +#define XCHAL_HAVE_XEA2 1 /* Exception Architecture 2 */ +#define XCHAL_HAVE_XEAX 0 /* External Exception Arch. */ +#define XCHAL_HAVE_EXCEPTIONS 1 /* exception option */ +#define XCHAL_HAVE_MEM_ECC_PARITY 0 /* local memory ECC/parity */ +#define XCHAL_HAVE_VECTOR_SELECT 1 /* relocatable vectors */ +#define XCHAL_HAVE_VECBASE 1 /* relocatable vectors */ +#define XCHAL_VECBASE_RESET_VADDR 0x40000000 /* VECBASE reset value */ +#define XCHAL_VECBASE_RESET_PADDR 0x40000000 +#define XCHAL_RESET_VECBASE_OVERLAP 0 + +#define XCHAL_RESET_VECTOR0_VADDR 0x50000000 +#define XCHAL_RESET_VECTOR0_PADDR 0x50000000 +#define XCHAL_RESET_VECTOR1_VADDR 0x40000080 +#define XCHAL_RESET_VECTOR1_PADDR 0x40000080 +#define XCHAL_RESET_VECTOR_VADDR 0x50000000 +#define XCHAL_RESET_VECTOR_PADDR 0x50000000 +#define XCHAL_USER_VECOFS 0x00000050 +#define XCHAL_USER_VECTOR_VADDR 0x40000050 +#define XCHAL_USER_VECTOR_PADDR 0x40000050 +#define XCHAL_KERNEL_VECOFS 0x00000030 +#define XCHAL_KERNEL_VECTOR_VADDR 0x40000030 +#define XCHAL_KERNEL_VECTOR_PADDR 0x40000030 +#define XCHAL_DOUBLEEXC_VECOFS 0x00000070 +#define XCHAL_DOUBLEEXC_VECTOR_VADDR 0x40000070 +#define XCHAL_DOUBLEEXC_VECTOR_PADDR 0x40000070 +#define XCHAL_INTLEVEL2_VECOFS 0x00000010 +#define XCHAL_INTLEVEL2_VECTOR_VADDR 0x40000010 +#define XCHAL_INTLEVEL2_VECTOR_PADDR 0x40000010 +#define XCHAL_DEBUG_VECOFS XCHAL_INTLEVEL2_VECOFS +#define XCHAL_DEBUG_VECTOR_VADDR XCHAL_INTLEVEL2_VECTOR_VADDR +#define XCHAL_DEBUG_VECTOR_PADDR XCHAL_INTLEVEL2_VECTOR_PADDR +#define XCHAL_NMI_VECOFS 0x00000020 +#define XCHAL_NMI_VECTOR_VADDR 0x40000020 +#define XCHAL_NMI_VECTOR_PADDR 0x40000020 +#define XCHAL_INTLEVEL3_VECOFS XCHAL_NMI_VECOFS +#define XCHAL_INTLEVEL3_VECTOR_VADDR XCHAL_NMI_VECTOR_VADDR +#define XCHAL_INTLEVEL3_VECTOR_PADDR XCHAL_NMI_VECTOR_PADDR + + +/*---------------------------------------------------------------------- + DEBUG + ----------------------------------------------------------------------*/ + +#define XCHAL_HAVE_OCD 1 /* OnChipDebug option */ +#define XCHAL_NUM_IBREAK 1 /* number of IBREAKn regs */ +#define XCHAL_NUM_DBREAK 1 /* number of DBREAKn regs */ +#define XCHAL_HAVE_OCD_DIR_ARRAY 0 /* faster OCD option */ + + +/*---------------------------------------------------------------------- + MMU + ----------------------------------------------------------------------*/ + +/* See core-matmap.h header file for more details. */ + +#define XCHAL_HAVE_TLBS 1 /* inverse of HAVE_CACHEATTR */ +#define XCHAL_HAVE_SPANNING_WAY 1 /* one way maps I+D 4GB vaddr */ +#define XCHAL_SPANNING_WAY 0 /* TLB spanning way number */ +#define XCHAL_HAVE_IDENTITY_MAP 1 /* vaddr == paddr always */ +#define XCHAL_HAVE_CACHEATTR 0 /* CACHEATTR register present */ +#define XCHAL_HAVE_MIMIC_CACHEATTR 1 /* region protection */ +#define XCHAL_HAVE_XLT_CACHEATTR 0 /* region prot. w/translation */ +#define XCHAL_HAVE_PTP_MMU 0 /* full MMU (with page table + [autorefill] and protection) + usable for an MMU-based OS */ +/* If none of the above last 4 are set, it's a custom TLB configuration. */ + +#define XCHAL_MMU_ASID_BITS 0 /* number of bits in ASIDs */ +#define XCHAL_MMU_RINGS 1 /* number of rings (1..4) */ +#define XCHAL_MMU_RING_BITS 0 /* num of bits in RING field */ + +#endif /* !XTENSA_HAL_NON_PRIVILEGED_ONLY */ + + +#endif /* _XTENSA_CORE_CONFIGURATION_H */ + diff --git a/libraries/GDBStub-source-level-debug/src/corebits.h b/libraries/GDBStub-source-level-debug/src/corebits.h new file mode 100644 index 0000000000..762bc60911 --- /dev/null +++ b/libraries/GDBStub-source-level-debug/src/corebits.h @@ -0,0 +1,164 @@ +/* + * xtensa/corebits.h - Xtensa Special Register field positions, masks, values. + * + * (In previous releases, these were defined in specreg.h, a generated file. + * This file is not generated, ie. it is processor configuration independent.) + */ + +/* $Id: //depot/rel/Boreal/Xtensa/OS/include/xtensa/corebits.h#2 $ */ + +/* + * Copyright (c) 2005-2007 Tensilica Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef XTENSA_COREBITS_H +#define XTENSA_COREBITS_H + +/* EXCCAUSE register fields: */ +#define EXCCAUSE_EXCCAUSE_SHIFT 0 +#define EXCCAUSE_EXCCAUSE_MASK 0x3F +/* EXCCAUSE register values: */ +/* + * General Exception Causes + * (values of EXCCAUSE special register set by general exceptions, + * which vector to the user, kernel, or double-exception vectors). + */ +#define EXCCAUSE_ILLEGAL 0 /* Illegal Instruction */ +#define EXCCAUSE_SYSCALL 1 /* System Call (SYSCALL instruction) */ +#define EXCCAUSE_INSTR_ERROR 2 /* Instruction Fetch Error */ +# define EXCCAUSE_IFETCHERROR 2 /* (backward compatibility macro, deprecated, avoid) */ +#define EXCCAUSE_LOAD_STORE_ERROR 3 /* Load Store Error */ +# define EXCCAUSE_LOADSTOREERROR 3 /* (backward compatibility macro, deprecated, avoid) */ +#define EXCCAUSE_LEVEL1_INTERRUPT 4 /* Level 1 Interrupt */ +# define EXCCAUSE_LEVEL1INTERRUPT 4 /* (backward compatibility macro, deprecated, avoid) */ +#define EXCCAUSE_ALLOCA 5 /* Stack Extension Assist (MOVSP instruction) for alloca */ +#define EXCCAUSE_DIVIDE_BY_ZERO 6 /* Integer Divide by Zero */ +#define EXCCAUSE_SPECULATION 7 /* Use of Failed Speculative Access (not implemented) */ +#define EXCCAUSE_PRIVILEGED 8 /* Privileged Instruction */ +#define EXCCAUSE_UNALIGNED 9 /* Unaligned Load or Store */ +/* Reserved 10..11 */ +#define EXCCAUSE_INSTR_DATA_ERROR 12 /* PIF Data Error on Instruction Fetch (RB-200x and later) */ +#define EXCCAUSE_LOAD_STORE_DATA_ERROR 13 /* PIF Data Error on Load or Store (RB-200x and later) */ +#define EXCCAUSE_INSTR_ADDR_ERROR 14 /* PIF Address Error on Instruction Fetch (RB-200x and later) */ +#define EXCCAUSE_LOAD_STORE_ADDR_ERROR 15 /* PIF Address Error on Load or Store (RB-200x and later) */ +#define EXCCAUSE_ITLB_MISS 16 /* ITLB Miss (no ITLB entry matches, hw refill also missed) */ +#define EXCCAUSE_ITLB_MULTIHIT 17 /* ITLB Multihit (multiple ITLB entries match) */ +#define EXCCAUSE_INSTR_RING 18 /* Ring Privilege Violation on Instruction Fetch */ +/* Reserved 19 */ /* Size Restriction on IFetch (not implemented) */ +#define EXCCAUSE_INSTR_PROHIBITED 20 /* Cache Attribute does not allow Instruction Fetch */ +/* Reserved 21..23 */ +#define EXCCAUSE_DTLB_MISS 24 /* DTLB Miss (no DTLB entry matches, hw refill also missed) */ +#define EXCCAUSE_DTLB_MULTIHIT 25 /* DTLB Multihit (multiple DTLB entries match) */ +#define EXCCAUSE_LOAD_STORE_RING 26 /* Ring Privilege Violation on Load or Store */ +/* Reserved 27 */ /* Size Restriction on Load/Store (not implemented) */ +#define EXCCAUSE_LOAD_PROHIBITED 28 /* Cache Attribute does not allow Load */ +#define EXCCAUSE_STORE_PROHIBITED 29 /* Cache Attribute does not allow Store */ +/* Reserved 30..31 */ +#define EXCCAUSE_CP_DISABLED(n) (32+(n)) /* Access to Coprocessor 'n' when disabled */ +#define EXCCAUSE_CP0_DISABLED 32 /* Access to Coprocessor 0 when disabled */ +#define EXCCAUSE_CP1_DISABLED 33 /* Access to Coprocessor 1 when disabled */ +#define EXCCAUSE_CP2_DISABLED 34 /* Access to Coprocessor 2 when disabled */ +#define EXCCAUSE_CP3_DISABLED 35 /* Access to Coprocessor 3 when disabled */ +#define EXCCAUSE_CP4_DISABLED 36 /* Access to Coprocessor 4 when disabled */ +#define EXCCAUSE_CP5_DISABLED 37 /* Access to Coprocessor 5 when disabled */ +#define EXCCAUSE_CP6_DISABLED 38 /* Access to Coprocessor 6 when disabled */ +#define EXCCAUSE_CP7_DISABLED 39 /* Access to Coprocessor 7 when disabled */ +/*#define EXCCAUSE_FLOATING_POINT 40*/ /* Floating Point Exception (not implemented) */ +/* Reserved 40..63 */ + +/* PS register fields: */ +#define PS_WOE_SHIFT 18 +#define PS_WOE_MASK 0x00040000 +#define PS_WOE PS_WOE_MASK +#define PS_CALLINC_SHIFT 16 +#define PS_CALLINC_MASK 0x00030000 +#define PS_CALLINC(n) (((n)&3)< +#include +void _xt_isr_attach(int inum, void *fn); +void _xt_isr_unmask(int inum); +void os_install_putc1(void (*p)(char c)); +#define os_printf(...) printf(__VA_ARGS__) +#define os_memcpy(a,b,c) memcpy(a,b,c) +typedef void wdtfntype(); +static wdtfntype *ets_wdt_disable=(wdtfntype *)0x400030f0; +static wdtfntype *ets_wdt_enable=(wdtfntype *)0x40002fa0; + +#else +/* +OS-less SDK defines. Defines some headers for things that aren't in the include files, plus +the xthal stack frame struct. +*/ +#include "osapi.h" +#include "user_interface.h" + +void _xtos_set_exception_handler(int cause, void (exhandler)(struct XTensa_exception_frame_s *frame)); +int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2))); + +#endif + +#define EXCEPTION_GDB_SP_OFFSET 0x100 + + +//We need some UART register defines. +#define ETS_UART_INUM 5 +#define REG_UART_BASE( i ) (0x60000000+(i)*0xf00) +#define UART_STATUS( i ) (REG_UART_BASE( i ) + 0x1C) +#define UART_RXFIFO_CNT 0x000000FF +#define UART_RXFIFO_CNT_S 0 +#define UART_TXFIFO_CNT 0x000000FF +#define UART_TXFIFO_CNT_S 16 +#define UART_FIFO( i ) (REG_UART_BASE( i ) + 0x0) +#define UART_INT_ENA(i) (REG_UART_BASE(i) + 0xC) +#define UART_INT_CLR(i) (REG_UART_BASE(i) + 0x10) +#define UART_RXFIFO_TOUT_INT_ENA (BIT(8)) +#define UART_RXFIFO_FULL_INT_ENA (BIT(0)) +#define UART_RXFIFO_TOUT_INT_CLR (BIT(8)) +#define UART_RXFIFO_FULL_INT_CLR (BIT(0)) + + + + +//Length of buffer used to reserve GDB commands. Has to be at least able to fit the G command, which +//implies a minimum size of about 190 bytes. +#define PBUFLEN 256 +//Length of gdb stdout buffer, for console redirection +#define OBUFLEN 32 + +//The asm stub saves the Xtensa registers here when a debugging exception happens. +struct XTensa_exception_frame_s gdbstub_savedRegs; +#if GDBSTUB_USE_OWN_STACK +//This is the debugging exception stack. +int exceptionStack[256]; +#endif + +static unsigned char cmd[PBUFLEN]; //GDB command input buffer +static char chsum; //Running checksum of the output packet +#if GDBSTUB_REDIRECT_CONSOLE_OUTPUT +static unsigned char obuf[OBUFLEN]; //GDB stdout buffer +static int obufpos=0; //Current position in the buffer +#endif +static int32_t singleStepPs=-1; //Stores ps when single-stepping instruction. -1 when not in use. + +//Small function to feed the hardware watchdog. Needed to stop the ESP from resetting +//due to a watchdog timeout while reading a command. +static void ATTR_GDBFN keepWDTalive() { + uint64_t *wdtval=(uint64_t*)0x3ff21048; + uint64_t *wdtovf=(uint64_t*)0x3ff210cc; + int *wdtctl=(int*)0x3ff210c8; + *wdtovf=*wdtval+1600000; + *wdtctl|=(1<<31); +} + +//Receive a char from the uart. Uses polling and feeds the watchdog. +static int ATTR_GDBFN gdbRecvChar() { + int i; + while (((READ_PERI_REG(UART_STATUS(0))>>UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT)==0) { + keepWDTalive(); + } + i=READ_PERI_REG(UART_FIFO(0)); + return i; +} + +//Send a char to the uart. +static void ATTR_GDBFN gdbSendChar(char c) { + while (((READ_PERI_REG(UART_STATUS(0))>>UART_TXFIFO_CNT_S)&UART_TXFIFO_CNT)>=126) ; + WRITE_PERI_REG(UART_FIFO(0), c); +} + +//Send the start of a packet; reset checksum calculation. +static void ATTR_GDBFN gdbPacketStart() { + chsum=0; + gdbSendChar('$'); +} + +//Send a char as part of a packet +static void ATTR_GDBFN gdbPacketChar(char c) { + if (c=='#' || c=='$' || c=='}' || c=='*') { + gdbSendChar('}'); + gdbSendChar(c^0x20); + chsum+=(c^0x20)+'}'; + } else { + gdbSendChar(c); + chsum+=c; + } +} + +//Send a string as part of a packet +static void ATTR_GDBFN gdbPacketStr(char *c) { + while (*c!=0) { + gdbPacketChar(*c); + c++; + } +} + +//Send a hex val as part of a packet. 'bits'/4 dictates the number of hex chars sent. +static void ATTR_GDBFN gdbPacketHex(int val, int bits) { + char hexChars[]="0123456789abcdef"; + int i; + for (i=bits; i>0; i-=4) { + gdbPacketChar(hexChars[(val>>(i-4))&0xf]); + } +} + +//Finish sending a packet. +static void ATTR_GDBFN gdbPacketEnd() { + gdbSendChar('#'); + gdbPacketHex(chsum, 8); +} + +//Error states used by the routines that grab stuff from the incoming gdb packet +#define ST_ENDPACKET -1 +#define ST_ERR -2 +#define ST_OK -3 +#define ST_CONT -4 + +//Grab a hex value from the gdb packet. Ptr will get positioned on the end +//of the hex string, as far as the routine has read into it. Bits/4 indicates +//the max amount of hex chars it gobbles up. Bits can be -1 to eat up as much +//hex chars as possible. +static long ATTR_GDBFN gdbGetHexVal(unsigned char **ptr, int bits) { + int i; + int no; + unsigned int v=0; + char c; + no=bits/4; + if (bits==-1) no=64; + for (i=0; i='0' && c<='9') { + v<<=4; + v|=(c-'0'); + } else if (c>='A' && c<='F') { + v<<=4; + v|=(c-'A')+10; + } else if (c>='a' && c<='f') { + v<<=4; + v|=(c-'a')+10; + } else if (c=='#') { + if (bits==-1) { + (*ptr)--; + return v; + } + return ST_ENDPACKET; + } else { + if (bits==-1) { + (*ptr)--; + return v; + } + return ST_ERR; + } + } + return v; +} + +//Swap an int into the form gdb wants it +static int ATTR_GDBFN iswap(int i) { + int r; + r=((i>>24)&0xff); + r|=((i>>16)&0xff)<<8; + r|=((i>>8)&0xff)<<16; + r|=((i>>0)&0xff)<<24; + return r; +} + +//Read a byte from the ESP8266 memory. +static unsigned char ATTR_GDBFN readbyte(unsigned int p) { + int *i=(int*)(p&(~3)); + if (p<0x20000000 || p>=0x60000000) return -1; + return *i>>((p&3)*8); +} + +//Write a byte to the ESP8266 memory. +static void ATTR_GDBFN writeByte(unsigned int p, unsigned char d) { + int *i=(int*)(p&(~3)); + if (p<0x20000000 || p>=0x60000000) return; + if ((p&3)==0) *i=(*i&0xffffff00)|(d<<0); + if ((p&3)==1) *i=(*i&0xffff00ff)|(d<<8); + if ((p&3)==2) *i=(*i&0xff00ffff)|(d<<16); + if ((p&3)==3) *i=(*i&0x00ffffff)|(d<<24); +} + +//Returns 1 if it makes sense to write to addr p +static int ATTR_GDBFN validWrAddr(int p) { + if (p>=0x3ff00000 && p<0x40000000) return 1; + if (p>=0x40100000 && p<0x40140000) return 1; + if (p>=0x60000000 && p<0x60002000) return 1; + return 0; +} + +/* +Register file in the format lx106 gdb port expects it. +Inspired by gdb/regformats/reg-xtensa.dat from +https://github.com/jcmvbkbc/crosstool-NG/blob/lx106-g%2B%2B/overlays/xtensa_lx106.tar +As decoded by Cesanta. +*/ +struct regfile { + uint32_t a[16]; + uint32_t pc; + uint32_t sar; + uint32_t litbase; + uint32_t sr176; + uint32_t sr208; + uint32_t ps; +}; + + +//Send the reason execution is stopped to GDB. +static void ATTR_GDBFN sendReason() { +#if 0 + char *reason=""; //default +#endif + //exception-to-signal mapping + char exceptionSignal[]={4,31,11,11,2,6,8,0,6,7,0,0,7,7,7,7}; + int i=0; + gdbPacketStart(); + gdbPacketChar('T'); + if (gdbstub_savedRegs.reason==0xff) { + gdbPacketHex(2, 8); //sigint + } else if (gdbstub_savedRegs.reason&0x80) { + //We stopped because of an exception. Convert exception code to a signal number and send it. + i=gdbstub_savedRegs.reason&0x7f; + if (i=PBUFLEN) return ST_ERR; + } + //A # has been received. Get and check the received chsum. + sentchs[0]=gdbRecvChar(); + sentchs[1]=gdbRecvChar(); + ptr=&sentchs[0]; + rchsum=gdbGetHexVal(&ptr, 8); +// os_printf("c %x r %x\n", chsum, rchsum); + if (rchsum!=chsum) { + gdbSendChar('-'); + return ST_ERR; + } else { + gdbSendChar('+'); + return gdbHandleCommand(cmd, p); + } +} + +//Get the value of one of the A registers +static unsigned int ATTR_GDBFN getaregval(int reg) { + if (reg==0) return gdbstub_savedRegs.a0; + if (reg==1) return gdbstub_savedRegs.a1; + return gdbstub_savedRegs.a[reg-2]; +} + +//Set the value of one of the A registers +static void ATTR_GDBFN setaregval(int reg, unsigned int val) { + os_printf("%x -> %x\n", val, reg); + if (reg==0) gdbstub_savedRegs.a0=val; + if (reg==1) gdbstub_savedRegs.a1=val; + gdbstub_savedRegs.a[reg-2]=val; +} + +//Emulate the l32i/s32i instruction we're stopped at. +static void ATTR_GDBFN emulLdSt() { + unsigned char i0=readbyte(gdbstub_savedRegs.pc); + unsigned char i1=readbyte(gdbstub_savedRegs.pc+1); + unsigned char i2=readbyte(gdbstub_savedRegs.pc+2); + int *p; + if ((i0&0xf)==2 && (i1&0xf0)==0x20) { + //l32i + p=(int*)getaregval(i1&0xf)+(i2*4); + setaregval(i0>>4, *p); + gdbstub_savedRegs.pc+=3; + } else if ((i0&0xf)==0x8) { + //l32i.n + p=(int*)getaregval(i1&0xf)+((i1>>4)*4); + setaregval(i0>>4, *p); + gdbstub_savedRegs.pc+=2; + } else if ((i0&0xf)==2 && (i1&0xf0)==0x60) { + //s32i + p=(int*)getaregval(i1&0xf)+(i2*4); + *p=getaregval(i0>>4); + gdbstub_savedRegs.pc+=3; + } else if ((i0&0xf)==0x9) { + //s32i.n + p=(int*)getaregval(i1&0xf)+((i1>>4)*4); + *p=getaregval(i0>>4); + gdbstub_savedRegs.pc+=2; + } else { + os_printf("GDBSTUB: No l32i/s32i instruction: %x %x %x. Huh?", i2, i1, i0); + } +} + +//We just caught a debug exception and need to handle it. This is called from an assembly +//routine in gdbstub-entry.S +void ATTR_GDBFN gdbstub_handle_debug_exception() { + ets_wdt_disable(); + + if (singleStepPs!=-1) { + //We come here after single-stepping an instruction. Interrupts are disabled + //for the single step. Re-enable them here. + gdbstub_savedRegs.ps=(gdbstub_savedRegs.ps&~0xf)|(singleStepPs&0xf); + singleStepPs=-1; + } + + sendReason(); + while(gdbReadCommand()!=ST_CONT); + if ((gdbstub_savedRegs.reason&0x84)==0x4) { + //We stopped due to a watchpoint. We can't re-execute the current instruction + //because it will happily re-trigger the same watchpoint, so we emulate it + //while we're still in debugger space. + emulLdSt(); + } else if ((gdbstub_savedRegs.reason&0x88)==0x8) { + //We stopped due to a BREAK instruction. Skip over it. + //Check the instruction first; gdb may have replaced it with the original instruction + //if it's one of the breakpoints it set. + if (readbyte(gdbstub_savedRegs.pc+2)==0 && + (readbyte(gdbstub_savedRegs.pc+1)&0xf0)==0x40 && + (readbyte(gdbstub_savedRegs.pc)&0x0f)==0x00) { + gdbstub_savedRegs.pc+=3; + } + } else if ((gdbstub_savedRegs.reason&0x90)==0x10) { + //We stopped due to a BREAK.N instruction. Skip over it, after making sure the instruction + //actually is a BREAK.N + if ((readbyte(gdbstub_savedRegs.pc+1)&0xf0)==0xf0 && + readbyte(gdbstub_savedRegs.pc)==0x2d) { + gdbstub_savedRegs.pc+=3; + } + } + ets_wdt_enable(); +} + + +#if GDBSTUB_FREERTOS +//Freetos exception. This routine is called by an assembly routine in gdbstub-entry.S +void ATTR_GDBFN gdbstub_handle_user_exception() { + ets_wdt_disable(); + gdbstub_savedRegs.reason|=0x80; //mark as an exception reason + sendReason(); + while(gdbReadCommand()!=ST_CONT); + ets_wdt_enable(); +} +#else + +//Non-OS exception handler. Gets called by the Xtensa HAL. +static void ATTR_GDBFN gdb_exception_handler(struct XTensa_exception_frame_s *frame) { + //Save the extra registers the Xtensa HAL doesn't save + gdbstub_save_extra_sfrs_for_exception(); + //Copy registers the Xtensa HAL did save to gdbstub_savedRegs + os_memcpy(&gdbstub_savedRegs, frame, 19*4); + //Credits go to Cesanta for this trick. A1 seems to be destroyed, but because it + //has a fixed offset from the address of the passed frame, we can recover it. + gdbstub_savedRegs.a1=(uint32_t)frame+EXCEPTION_GDB_SP_OFFSET; + + gdbstub_savedRegs.reason|=0x80; //mark as an exception reason + + ets_wdt_disable(); + sendReason(); + while(gdbReadCommand()!=ST_CONT); + ets_wdt_enable(); + + //Copy any changed registers back to the frame the Xtensa HAL uses. + os_memcpy(frame, &gdbstub_savedRegs, 19*4); +} +#endif + +#if GDBSTUB_REDIRECT_CONSOLE_OUTPUT +//Replacement putchar1 routine. Instead of spitting out the character directly, it will buffer up to +//OBUFLEN characters (or up to a \n, whichever comes earlier) and send it out as a gdb stdout packet. +static void ATTR_GDBFN gdb_semihost_putchar1(char c) { + int i; + obuf[obufpos++]=c; + if (c=='\n' || obufpos==OBUFLEN) { + gdbPacketStart(); + gdbPacketChar('O'); + for (i=0; i>UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT; + while (fifolen!=0) { + if ((READ_PERI_REG(UART_FIFO(0)) & 0xFF)==0x3) doDebug=1; //Check if any of the chars is control-C. Throw away rest. + fifolen--; + } + WRITE_PERI_REG(UART_INT_CLR(0), UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR); + + if (doDebug) { + //Copy registers the Xtensa HAL did save to gdbstub_savedRegs + os_memcpy(&gdbstub_savedRegs, frame, 19*4); + gdbstub_savedRegs.a1=(uint32_t)frame+EXCEPTION_GDB_SP_OFFSET; + + gdbstub_savedRegs.reason=0xff; //mark as user break reason + + ets_wdt_disable(); + sendReason(); + while(gdbReadCommand()!=ST_CONT); + ets_wdt_enable(); + //Copy any changed registers back to the frame the Xtensa HAL uses. + os_memcpy(frame, &gdbstub_savedRegs, 19*4); + } +} + +static void ATTR_GDBINIT install_uart_hdlr() { + ets_isr_attach(ETS_UART_INUM, uart_hdlr, NULL); + SET_PERI_REG_MASK(UART_INT_ENA(0), UART_RXFIFO_FULL_INT_ENA|UART_RXFIFO_TOUT_INT_ENA); + ets_isr_unmask((1<>UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT; + while (fifolen!=0) { + if ((READ_PERI_REG(UART_FIFO(0)) & 0xFF)==0x3) doDebug=1; //Check if any of the chars is control-C. Throw away rest. + fifolen--; + } + WRITE_PERI_REG(UART_INT_CLR(0), UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR); + + if (doDebug) { + //Copy registers the Xtensa HAL did save to gdbstub_savedRegs + gdbstub_savedRegs.pc=frame->pc; + gdbstub_savedRegs.ps=frame->ps; + gdbstub_savedRegs.sar=frame->sar; + gdbstub_savedRegs.a0=frame->a[0]; + gdbstub_savedRegs.a1=frame->a[1]; + for (x=2; x<16; x++) gdbstub_savedRegs.a[x-2]=frame->a[x]; + +// gdbstub_savedRegs.a1=(uint32_t)frame+EXCEPTION_GDB_SP_OFFSET; + + gdbstub_savedRegs.reason=0xff; //mark as user break reason + +// ets_wdt_disable(); + sendReason(); + while(gdbReadCommand()!=ST_CONT); +// ets_wdt_enable(); + //Copy any changed registers back to the frame the Xtensa HAL uses. + frame->pc=gdbstub_savedRegs.pc; + frame->ps=gdbstub_savedRegs.ps; + frame->sar=gdbstub_savedRegs.sar; + frame->a[0]=gdbstub_savedRegs.a0; + frame->a[1]=gdbstub_savedRegs.a1; + for (x=2; x<16; x++) frame->a[x]=gdbstub_savedRegs.a[x-2]; + } +} + +static void ATTR_GDBINIT install_uart_hdlr() { + _xt_isr_attach(ETS_UART_INUM, gdbstub_uart_entry); + SET_PERI_REG_MASK(UART_INT_ENA(0), UART_RXFIFO_FULL_INT_ENA|UART_RXFIFO_TOUT_INT_ENA); + _xt_isr_unmask((1<