xmon.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* xmon.h - XMON definitions
  2. *
  3. * $Id: //depot/rel/Eaglenest/Xtensa/OS/xmon/xmon.h#3 $
  4. *
  5. * Copyright (c) 2001-2013 Tensilica Inc.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining
  8. * a copy of this software and associated documentation files (the
  9. * "Software"), to deal in the Software without restriction, including
  10. * without limitation the rights to use, copy, modify, merge, publish,
  11. * distribute, sublicense, and/or sell copies of the Software, and to
  12. * permit persons to whom the Software is furnished to do so, subject to
  13. * the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included
  16. * in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  21. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  22. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. */
  26. #ifndef __H_XMON
  27. #define __H_XMON
  28. /* Default GDB packet size */
  29. #define GDB_PKT_SIZE 4096
  30. /*XMON signals */
  31. #define XMON_SIGINT 2 /*target was interrupted */
  32. #define XMON_SIGILL 4 /*illegal instruction */
  33. #define XMON_SIGTRAP 5 /*general exception */
  34. #define XMON_SIGSEGV 11 /*page faults */
  35. /* Type of log message from XMON to the application */
  36. typedef enum {
  37. XMON_LOG,
  38. XMON_TRACE,
  39. XMON_ERR,
  40. XMON_APP,
  41. XMON_GDB
  42. } xmon_log_t;
  43. /* Return value type for xmon_proc() (see below) */
  44. typedef enum {
  45. XMON_GDB_PEND,
  46. XMON_GDB_PKT,
  47. XMON_NOT_GDB
  48. } xmon_gdb_pkt_t;
  49. #ifdef _cplusplus
  50. extern "C" {
  51. #endif
  52. /*
  53. * THE FOLLOWING ROUTINES ARE USED BY USER
  54. */
  55. extern int _xmon_init(char* gdbBuf, int gdbPktSize,
  56. void(*xlog)(xmon_log_t type, const char* str));
  57. //Initialize GDB communication and logging to the main app.
  58. //For the logging to work, xlog function needs to be provided.
  59. //gdbBuf - pointer to a buffer XMON can use to comm. with GDB
  60. //gdbPktSize - Size of the allocated buffer for GDB communication.
  61. //xlog - logger handle.
  62. extern void _xmon_close(void);
  63. //Main application can detach from xmon at any time
  64. extern xmon_gdb_pkt_t _xmon_proc(char);
  65. // Give character to XMON to check if GDB message
  66. // Application is supposed to accumulate all the
  67. // character in case the recognition fails and chars
  68. // have to be sent to the original handler
  69. // Return: XMON_GDB_PEND - send me more chars
  70. // XMON_GDB_PKT - GDB message confirmed, C) not
  71. // XMON_NOT_GDB - not GDB message
  72. /*
  73. * THE FOLLOWING ROUTINES NEED TO BE PROVIDED BY USER
  74. */
  75. extern int _xmon_in(); // wait for character from GDB
  76. extern void _xmon_out(char); // output a character to GDB
  77. extern int _xmon_flush(void); // flush output characters
  78. #ifdef _cplusplus
  79. }
  80. #endif
  81. #endif