You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

102 lines
4.6 KiB

  1. /***************************************************************************
  2. * *
  3. * Copyright (C) ST-Ericsson SA 2011 *
  4. * Author: Michel Jaouen <michel.jaouen@stericsson.com> for ST-Ericsson. *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19. ***************************************************************************/
  20. #ifdef HAVE_CONFIG_H
  21. #include "config.h"
  22. #endif
  23. #include "server/server.h"
  24. #include "target/target.h"
  25. #include "server/gdb_server.h"
  26. #include "smp.h"
  27. #include "helper/binarybuffer.h"
  28. /* implementation of new packet in gdb interface for smp feature */
  29. /* */
  30. /* j : smp status request */
  31. /* J : smp set request */
  32. /* */
  33. /* jc :read core id displayed by gdb connection */
  34. /* reply XXXXXXXX core id is int32_t , 8 hex digits */
  35. /* */
  36. /* Reply ENN error not supported (target not smp) */
  37. /* */
  38. /* JcXX set core id displayed at next gdb continue */
  39. /* maximum 8 bytes described core id int32_t (8 hex digits) */
  40. /* (core id -1 , reserved for returning to normal continue mode) */
  41. /* Reply ENN error not supported(target not smp,core id out of range) */
  42. /* Reply OK : for success */
  43. /* */
  44. /* handling of this packet within gdb can be done by the creation */
  45. /* internal variable by mean of function allocate_computed_value */
  46. /* set $_core 1 => Jc01 packet is sent */
  47. /* print $_core => jc packet is sent and result is affected in $ */
  48. /* Another way to test this packet is the usage of maintenance packet */
  49. /* maint packet Jc01 */
  50. /* maint packet jc */
  51. /* packet j :smp status request */
  52. int gdb_read_smp_packet(struct connection *connection,
  53. char *packet, int packet_size)
  54. {
  55. struct target *target = get_target_from_connection(connection);
  56. uint32_t len = sizeof(int32_t);
  57. uint8_t *buffer;
  58. char *hex_buffer;
  59. int retval = ERROR_OK;
  60. if (target->smp) {
  61. if (strncmp(packet, "jc", 2) == 0) {
  62. hex_buffer = malloc(len * 2 + 1);
  63. buffer = (uint8_t *)&target->gdb_service->core[0];
  64. int pkt_len = hexify(hex_buffer, (char *)buffer, len, len * 2 + 1);
  65. retval = gdb_put_packet(connection, hex_buffer, pkt_len);
  66. free(hex_buffer);
  67. }
  68. } else
  69. retval = gdb_put_packet(connection, "E01", 3);
  70. return retval;
  71. }
  72. /* J : smp set request */
  73. int gdb_write_smp_packet(struct connection *connection,
  74. char *packet, int packet_size)
  75. {
  76. struct target *target = get_target_from_connection(connection);
  77. char *separator;
  78. int coreid = 0;
  79. int retval = ERROR_OK;
  80. /* skip command character */
  81. if (target->smp) {
  82. if (strncmp(packet, "Jc", 2) == 0) {
  83. packet += 2;
  84. coreid = strtoul(packet, &separator, 16);
  85. target->gdb_service->core[1] = coreid;
  86. retval = gdb_put_packet(connection, "OK", 2);
  87. }
  88. } else
  89. retval = gdb_put_packet(connection, "E01", 3);
  90. return retval;
  91. }