Semihosting.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. #if !defined( __CC_ARM )
  61. virtual void ImportPattern_f16(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  62. #endif
  63. virtual void ImportPattern_q63(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  64. virtual void ImportPattern_q31(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  65. virtual void ImportPattern_q15(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  66. virtual void ImportPattern_q7(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  67. virtual void ImportPattern_u32(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  68. virtual void ImportPattern_u16(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  69. virtual void ImportPattern_u8(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  70. virtual void DumpParams(std::vector<Testing::param_t>&);
  71. virtual Testing::param_t* ImportParams(Testing::PatternID_t,Testing::nbParameterEntries_t &,Testing::ParameterKind &);
  72. virtual bool hasParam();
  73. virtual Testing::PatternID_t getParamID();
  74. virtual void DumpPattern_f64(Testing::outputID_t,Testing::nbSamples_t nb, float64_t*);
  75. virtual void DumpPattern_f32(Testing::outputID_t,Testing::nbSamples_t nb, float32_t*);
  76. #if !defined( __CC_ARM )
  77. virtual void DumpPattern_f16(Testing::outputID_t,Testing::nbSamples_t nb, float16_t*);
  78. #endif
  79. virtual void DumpPattern_q63(Testing::outputID_t,Testing::nbSamples_t nb, q63_t*);
  80. virtual void DumpPattern_q31(Testing::outputID_t,Testing::nbSamples_t nb, q31_t*);
  81. virtual void DumpPattern_q15(Testing::outputID_t,Testing::nbSamples_t nb, q15_t*);
  82. virtual void DumpPattern_q7(Testing::outputID_t,Testing::nbSamples_t nb, q7_t*);
  83. virtual void DumpPattern_u32(Testing::outputID_t,Testing::nbSamples_t nb, uint32_t*);
  84. virtual void DumpPattern_u16(Testing::outputID_t,Testing::nbSamples_t nb, uint16_t*);
  85. virtual void DumpPattern_u8(Testing::outputID_t,Testing::nbSamples_t nb, uint8_t*);
  86. virtual Testing::testID_t CurrentTestID();
  87. private:
  88. void DeleteParams();
  89. void recomputeTestDir();
  90. // Get the path to a pattern from a pattern ID
  91. std::string getPatternPath(Testing::PatternID_t id);
  92. // Get a path to an output file from an ouput category
  93. // (test ID will be used so same output ID
  94. // is giving different names for different tests)
  95. std::string getOutputPath(Testing::outputID_t id);
  96. // Get description of parameters from parameter ID
  97. struct pathOrGen getParameterDesc(Testing::PatternID_t id);
  98. // Get file size from local path
  99. Testing::nbSamples_t GetFileSize(std::string &path);
  100. // Driver filer controlling the tests.
  101. FILE* infile;
  102. // Node description (group, suite or test)
  103. int currentKind;
  104. // Node ID
  105. Testing::testID_t currentId;
  106. // Current param ID for the node
  107. Testing::PatternID_t currentParam;
  108. bool m_hasParam;
  109. // Current path for the node
  110. // (It is not the full path but the path added by this node)
  111. std::string currentPath;
  112. // Contains the current test directory
  113. // (where to find pattenrs)
  114. std::string testDir;
  115. // Array of folder used to build the
  116. // testDir parth
  117. std::vector<std::string> *path;
  118. // Root directory for patterns
  119. std::string patternRootPath;
  120. // Root directory for output
  121. std::string outputRootPath;
  122. // Root directory for parameters
  123. std::string parameterRootPath;
  124. // List of pattern filenames
  125. // Used to find a name from a pattern ID
  126. std::vector<std::string> *patternFilenames;
  127. // List of output names
  128. // Used to find a name from an output ID
  129. std::vector<std::string> *outputNames;
  130. // List of parameters descriptions
  131. // Used to find a path or generator from a parameter ID
  132. std::vector<struct pathOrGen> *parameterNames;
  133. };
  134. }
  135. #endif