ARPCPrint.1.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * void ARPCPrint (FILE * fp, void const * memory, size_t extent);
  11. *
  12. * mme.h
  13. *
  14. * print formatted VS_ARPC payload on the specified output stream;
  15. * this implementation is generic; memory is the start address of
  16. * the message data (&RDATA [RDATAOFFSET]) and extent is the data
  17. * length (RDATALENGTH); the call might look like this ...
  18. *
  19. * ARPCPrint (fp, &ARPC->RDATA [ARPC->RDATAOFFSET], LE16TOH (ARPC->RDATALENGTH) - ARPC->RDATAOFFSET);
  20. *
  21. * ... where LE16TOH () performs 16-bit host endian conversion;
  22. *
  23. *
  24. * Contributor(s):
  25. * Charles Maier <cmaier@qca.qualcomm.com>
  26. * Nathaniel Houghton <nhoughto@qca.qualcomm.com>
  27. * Florian Fainelli <f.fainelli@gmail.com>
  28. *
  29. *--------------------------------------------------------------------*/
  30. #ifndef ARPCPRINT_SOURCE
  31. #define ARPCPRINT_SOURCE
  32. #include <stdio.h>
  33. #include <stddef.h>
  34. #include "../tools/types.h"
  35. #include "../tools/endian.h"
  36. #include "../tools/memory.h"
  37. #include "../mme/mme.h"
  38. void ARPCPrint (FILE * fp, void const * memory, size_t extent)
  39. {
  40. #ifndef __GNUC__
  41. #pragma pack (push,1)
  42. #endif
  43. struct __packed vs_arpc_data
  44. {
  45. uint32_t BYPASS;
  46. uint16_t ARPCID;
  47. uint16_t DATALENGTH;
  48. uint8_t DATAOFFSET;
  49. uint8_t RESERVED [3];
  50. uint16_t ARGOFFSET;
  51. uint16_t STROFFSET;
  52. uint16_t ARGLENGTH;
  53. uint16_t STRLENGTH;
  54. uint8_t LIST [1];
  55. }
  56. * data = (struct vs_arpc_data *)(memory);
  57. #ifndef __GNUC__
  58. #pragma pack (pop)
  59. #endif
  60. uint32_t * argp = (uint32_t *)(&data->LIST [LE16TOH (data->ARGOFFSET)]);
  61. uint16_t argc = LE16TOH (data->ARGLENGTH) >> 2;
  62. while (argc--)
  63. {
  64. *argp = LE32TOH (*argp);
  65. argp++;
  66. }
  67. #if defined (__UCLIBC__) || defined (__FREESCALE__)
  68. /*
  69. * This is a temporary fix so that we can compile program plctest for the PL16; A better solution is needed;
  70. */
  71. argp = (uint32_t *)(&data->LIST [LE16TOH (data->ARGOFFSET)]);
  72. fprintf (fp, (char *)(&data->LIST [LE16TOH (data->STROFFSET)]), argp [0], argp [1], argp [2], argp [3], argp [4], argp [5], argp [6], argp [7], argp [8], argp [9], argp [10], argp [11], argp [12], argp [13], argp [14], argp [15], argp [16], argp [17], argp [18], argp [19], argp [20], argp [21], argp [22], argp [23], argp [24], argp [25], argp [26], argp [27], argp [28], argp [29], argp [30], argp [31], argp [32], argp [33], argp [34], argp [35], argp [36], argp [37], argp [38], argp [39]);
  73. #else
  74. vfprintf (fp, (char *)(&data->LIST [LE16TOH (data->STROFFSET)]), (void *)(&data->LIST [LE16TOH (data->ARGOFFSET)]));
  75. #endif
  76. fprintf (fp, "\n");
  77. fflush (fp);
  78. return;
  79. }
  80. #endif