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.
 
 
 
 
 
 

99 lines
4.4 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, see <http://www.gnu.org/licenses/>. *
  17. ***************************************************************************/
  18. #ifdef HAVE_CONFIG_H
  19. #include "config.h"
  20. #endif
  21. #include "server/server.h"
  22. #include "target/target.h"
  23. #include "server/gdb_server.h"
  24. #include "smp.h"
  25. #include "helper/binarybuffer.h"
  26. /* implementation of new packet in gdb interface for smp feature */
  27. /* */
  28. /* j : smp status request */
  29. /* J : smp set request */
  30. /* */
  31. /* jc :read core id displayed by gdb connection */
  32. /* reply XXXXXXXX core id is int32_t , 8 hex digits */
  33. /* */
  34. /* Reply ENN error not supported (target not smp) */
  35. /* */
  36. /* JcXX set core id displayed at next gdb continue */
  37. /* maximum 8 bytes described core id int32_t (8 hex digits) */
  38. /* (core id -1 , reserved for returning to normal continue mode) */
  39. /* Reply ENN error not supported(target not smp,core id out of range) */
  40. /* Reply OK : for success */
  41. /* */
  42. /* handling of this packet within gdb can be done by the creation */
  43. /* internal variable by mean of function allocate_computed_value */
  44. /* set $_core 1 => Jc01 packet is sent */
  45. /* print $_core => jc packet is sent and result is affected in $ */
  46. /* Another way to test this packet is the usage of maintenance packet */
  47. /* maint packet Jc01 */
  48. /* maint packet jc */
  49. /* packet j :smp status request */
  50. int gdb_read_smp_packet(struct connection *connection,
  51. char const *packet, int packet_size)
  52. {
  53. struct target *target = get_target_from_connection(connection);
  54. int retval = ERROR_OK;
  55. if (target->smp) {
  56. if (strncmp(packet, "jc", 2) == 0) {
  57. const uint32_t len = sizeof(target->gdb_service->core[0]);
  58. char hex_buffer[len * 2 + 1];
  59. uint8_t buffer[len];
  60. buf_set_u32(buffer, 0, len * 8, target->gdb_service->core[0]);
  61. size_t pkt_len = hexify(hex_buffer, buffer, sizeof(buffer),
  62. sizeof(hex_buffer));
  63. retval = gdb_put_packet(connection, hex_buffer, pkt_len);
  64. }
  65. } else
  66. retval = gdb_put_packet(connection, "E01", 3);
  67. return retval;
  68. }
  69. /* J : smp set request */
  70. int gdb_write_smp_packet(struct connection *connection,
  71. char const *packet, int packet_size)
  72. {
  73. struct target *target = get_target_from_connection(connection);
  74. char *separator;
  75. int coreid = 0;
  76. int retval = ERROR_OK;
  77. /* skip command character */
  78. if (target->smp) {
  79. if (strncmp(packet, "Jc", 2) == 0) {
  80. packet += 2;
  81. coreid = strtoul(packet, &separator, 16);
  82. target->gdb_service->core[1] = coreid;
  83. retval = gdb_put_packet(connection, "OK", 2);
  84. }
  85. } else
  86. retval = gdb_put_packet(connection, "E01", 3);
  87. return retval;
  88. }