fix definition of __debugbreak() so if (1) __debugbreak(); else blah(); works as...
[clinton/Smoothieware.git] / mri / mri.h
... / ...
CommitLineData
1/* Copyright 2012 Adam Green (http://mbed.org/users/AdamGreen/)\r
2\r
3 This program is free software: you can redistribute it and/or modify\r
4 it under the terms of the GNU Lesser General Public License as published\r
5 by the Free Software Foundation, either version 3 of the License, or\r
6 (at your option) any later version.\r
7\r
8 This program is distributed in the hope that it will be useful,\r
9 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
11 GNU Lesser General Public License for more details.\r
12\r
13 You should have received a copy of the GNU Lesser General Public License\r
14 along with this program. If not, see <http://www.gnu.org/licenses/>. \r
15*/\r
16/* Monitor for Remote Inspection. */\r
17#ifndef _MRI_H_\r
18#define _MRI_H_\r
19\r
20#include <stdint.h>\r
21\r
22/* Used to insert hardcoded breakpoint into user's code. */\r
23#define __debugbreak() do { __asm volatile ("bkpt #0"); } while (0)\r
24\r
25/* Error strings that can be returned to GDB. */\r
26#define MRI_ERROR_INVALID_ARGUMENT "E01" /* Encountered error when parsing command arguments. */\r
27#define MRI_ERROR_MEMORY_ACCESS_FAILURE "E03" /* Couldn't access requested memory. */\r
28#define MRI_ERROR_BUFFER_OVERRUN "E04" /* Overflowed internal input/output buffer. */\r
29#define MRI_ERROR_NO_FREE_BREAKPOINT "E05" /* No free FPB breakpoint comparator slots. */\r
30\r
31\r
32#ifdef __cplusplus\r
33extern "C"\r
34{\r
35#endif\r
36\r
37\r
38/* pDebuggerParameters string passed into __mriInit contains a space separated list of configuration parameters to be\r
39 used to initialize the debug monitor. The supported options include:\r
40 \r
41 One of these options to indicate which UART to be used for the debugger connection:\r
42 MRI_UART_MBED_USB\r
43 MRI_UART_MBED_P9_P10\r
44 MRI_UART_MBED_P13_P14\r
45 MRI_UART_MBED_P28_P27\r
46 MRI_UART_0\r
47 MRI_UART_1\r
48 MRI_UART_2\r
49 MRI_UART_3\r
50 \r
51 By default the debug monitor expects to take full control of the UART to configure baud rate, etc. However \r
52 including the following option will tell the monitor to assume that the user's firmware will configure and use the\r
53 serial port until the first exception occurs:\r
54 MRI_UART_SHARE\r
55 \r
56 When not sharing the UART, MRI will typically try to use the auto-baud functionality of the device so that the user\r
57 can select the desired baud rate when they start GDB. However it is possible to override this in the init string.\r
58 For example the following option would set the baud rate to 230400 (note that spaces aren't allowed before or after\r
59 the '=' character):\r
60 MRI_UART_BAUD=230400\r
61 NOTE: LPC176x version of MRI supports a maximum baud rate of 3Mbaud and the core clock can't run faster than\r
62 128MHz or calculating baud rate divisors will fail.\r
63*/\r
64void __mriInit(const char* pDebuggerParameters);\r
65\r
66\r
67/* Simple assembly language stubs that can be called from user's newlib stubs routines which will cause the operations\r
68 to be redirected to the GDB host via MRI. */\r
69int __mriNewLib_SemihostOpen(const char *pFilename, int flags, int mode);\r
70int __mriNewLib_SemihostRename(const char *pOldFilename, const char *pNewFilename);\r
71int __mriNewLib_SemihostUnlink(const char *pFilename);\r
72int __mriNewLib_SemihostStat(const char *pFilename, void *pStat);\r
73int __mriNewlib_SemihostWrite(int file, const char *ptr, int len);\r
74int __mriNewlib_SemihostRead(int file, char *ptr, int len);\r
75int __mriNewlib_SemihostLSeek(int file, int offset, int whence);\r
76int __mriNewlib_SemihostClose(int file);\r
77int __mriNewlib_SemihostFStat(int file, void *pStat);\r
78\r
79\r
80\r
81/* Can be used by semihosting hooks to determine the index of the UART being used by MRI. */\r
82int __mriPlatform_CommUartIndex(void);\r
83\r
84\r
85#ifdef __cplusplus\r
86}\r
87#endif\r
88\r
89#endif /* _MRI_H_ */\r
90\r
91\r
92#ifndef MRI_VERSION_STRING\r
93\r
94#define MRI_BRANCH "https://github.com/adamgreen/mri/tree/version_0.5"\r
95\r
96#define MRI_VERSION_MAJOR 0\r
97#define MRI_VERSION_MINOR 5\r
98#define MRI_VERSION_BUILD 20130120\r
99#define MRI_VERSION_SUBBUILD 1\r
100\r
101#define MRI_STR(X) MRI_STR2(X)\r
102#define MRI_STR2(X) #X\r
103\r
104#define MRI_VERSION_STRING MRI_STR(MRI_VERSION_MAJOR) "." MRI_STR(MRI_VERSION_MINOR) "-" MRI_STR(MRI_VERSION_BUILD) "." MRI_STR(MRI_VERSION_SUBBUILD)\r
105\r
106#endif\r