Semihosting.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: Semihosting.h
  4. * Description: Semihosting Header
  5. *
  6. * $Date: 20. June 2019
  7. * $Revision: V1.0.0
  8. *
  9. * Target Processor: Cortex-M cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
  13. *
  14. * SPDX-License-Identifier: Apache-2.0
  15. *
  16. * Licensed under the Apache License, Version 2.0 (the License); you may
  17. * not use this file except in compliance with the License.
  18. * You may obtain a copy of the License at
  19. *
  20. * www.apache.org/licenses/LICENSE-2.0
  21. *
  22. * Unless required by applicable law or agreed to in writing, software
  23. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  24. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25. * See the License for the specific language governing permissions and
  26. * limitations under the License.
  27. */
  28. #ifndef _SEMIHOSTING_H_
  29. #define _SEMIHOSTING_H_
  30. #include <string>
  31. #include <memory>
  32. #include <stdio.h>
  33. namespace Client
  34. {
  35. /*
  36. Semihosting driver. Used to read a text file describing how to drive the test.
  37. */
  38. struct pathOrGen;
  39. class Semihosting:public IO
  40. {
  41. public:
  42. Semihosting(std::string path,std::string patternRootPath
  43. ,std::string outputRootPath
  44. ,std::string parameterRootPath);
  45. ~Semihosting();
  46. virtual void ReadIdentification();
  47. virtual void ReadTestIdentification();
  48. virtual Testing::nbParameters_t ReadNbParameters();
  49. virtual void DispStatus(Testing::TestStatus,Testing::errorID_t,unsigned long,Testing::cycles_t);
  50. virtual void DispErrorDetails(const char* );
  51. virtual void EndGroup();
  52. virtual void ImportPattern(Testing::PatternID_t);
  53. virtual void ReadPatternList();
  54. virtual void ReadOutputList();
  55. virtual void ReadParameterList(Testing::nbParameters_t);
  56. virtual Testing::nbSamples_t GetPatternSize(Testing::PatternID_t);
  57. //Testing::nbSamples_t GetParameterSize(Testing::PatternID_t);
  58. virtual void ImportPattern_f64(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  59. virtual void ImportPattern_f32(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  60. virtual void ImportPattern_q63(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  61. virtual void ImportPattern_q31(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  62. virtual void ImportPattern_q15(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  63. virtual void ImportPattern_q7(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  64. virtual void ImportPattern_u32(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  65. virtual void ImportPattern_u16(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  66. virtual void ImportPattern_u8(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  67. virtual void DumpParams(std::vector<Testing::param_t>&);
  68. virtual Testing::param_t* ImportParams(Testing::PatternID_t,Testing::nbParameterEntries_t &,Testing::ParameterKind &);
  69. virtual bool hasParam();
  70. virtual Testing::PatternID_t getParamID();
  71. virtual void DumpPattern_f64(Testing::outputID_t,Testing::nbSamples_t nb, float64_t*);
  72. virtual void DumpPattern_f32(Testing::outputID_t,Testing::nbSamples_t nb, float32_t*);
  73. virtual void DumpPattern_q63(Testing::outputID_t,Testing::nbSamples_t nb, q63_t*);
  74. virtual void DumpPattern_q31(Testing::outputID_t,Testing::nbSamples_t nb, q31_t*);
  75. virtual void DumpPattern_q15(Testing::outputID_t,Testing::nbSamples_t nb, q15_t*);
  76. virtual void DumpPattern_q7(Testing::outputID_t,Testing::nbSamples_t nb, q7_t*);
  77. virtual void DumpPattern_u32(Testing::outputID_t,Testing::nbSamples_t nb, uint32_t*);
  78. virtual void DumpPattern_u16(Testing::outputID_t,Testing::nbSamples_t nb, uint16_t*);
  79. virtual void DumpPattern_u8(Testing::outputID_t,Testing::nbSamples_t nb, uint8_t*);
  80. virtual Testing::testID_t CurrentTestID();
  81. private:
  82. void DeleteParams();
  83. void recomputeTestDir();
  84. // Get the path to a pattern from a pattern ID
  85. std::string getPatternPath(Testing::PatternID_t id);
  86. // Get a path to an output file from an ouput category
  87. // (test ID will be used so same output ID
  88. // is giving different names for different tests)
  89. std::string getOutputPath(Testing::outputID_t id);
  90. // Get description of parameters from parameter ID
  91. struct pathOrGen getParameterDesc(Testing::PatternID_t id);
  92. // Get file size from local path
  93. Testing::nbSamples_t GetFileSize(std::string &path);
  94. // Driver filer controlling the tests.
  95. FILE* infile;
  96. // Node description (group, suite or test)
  97. int currentKind;
  98. // Node ID
  99. Testing::testID_t currentId;
  100. // Current param ID for the node
  101. Testing::PatternID_t currentParam;
  102. bool m_hasParam;
  103. // Current path for the node
  104. // (It is not the full path but the path added by this node)
  105. std::string currentPath;
  106. // Contains the current test directory
  107. // (where to find pattenrs)
  108. std::string testDir;
  109. // Array of folder used to build the
  110. // testDir parth
  111. std::vector<std::string> *path;
  112. // Root directory for patterns
  113. std::string patternRootPath;
  114. // Root directory for output
  115. std::string outputRootPath;
  116. // Root directory for parameters
  117. std::string parameterRootPath;
  118. // List of pattern filenames
  119. // Used to find a name from a pattern ID
  120. std::vector<std::string> *patternFilenames;
  121. // List of output names
  122. // Used to find a name from an output ID
  123. std::vector<std::string> *outputNames;
  124. // List of parameters descriptions
  125. // Used to find a path or generator from a parameter ID
  126. std::vector<struct pathOrGen> *parameterNames;
  127. };
  128. }
  129. #endif