Semihosting.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 <cstdio>
  33. #include "arm_math_types.h"
  34. #include "arm_math_types_f16.h"
  35. namespace Client
  36. {
  37. /*
  38. Semihosting driver. Used to read a text file describing how to drive the test.
  39. */
  40. struct pathOrGen;
  41. class Semihosting:public IO
  42. {
  43. public:
  44. Semihosting(std::string path,std::string patternRootPath
  45. ,std::string outputRootPath
  46. ,std::string parameterRootPath);
  47. ~Semihosting();
  48. virtual void ReadIdentification();
  49. virtual void ReadTestIdentification();
  50. virtual Testing::nbParameters_t ReadNbParameters();
  51. virtual void DispStatus(Testing::TestStatus,Testing::errorID_t,unsigned long,Testing::cycles_t);
  52. virtual void DispErrorDetails(const char* );
  53. virtual void EndGroup();
  54. virtual void ImportPattern(Testing::PatternID_t);
  55. virtual void ReadPatternList();
  56. virtual void ReadOutputList();
  57. virtual void ReadParameterList(Testing::nbParameters_t);
  58. virtual Testing::nbSamples_t GetPatternSize(Testing::PatternID_t);
  59. //Testing::nbSamples_t GetParameterSize(Testing::PatternID_t);
  60. virtual void ImportPattern_f64(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  61. virtual void ImportPattern_f32(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  62. #if !defined( __CC_ARM ) && defined(ARM_FLOAT16_SUPPORTED)
  63. virtual void ImportPattern_f16(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  64. #endif
  65. virtual void ImportPattern_q63(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  66. virtual void ImportPattern_q31(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  67. virtual void ImportPattern_q15(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  68. virtual void ImportPattern_q7(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  69. virtual void ImportPattern_u32(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  70. virtual void ImportPattern_u16(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  71. virtual void ImportPattern_u8(Testing::PatternID_t,char*,Testing::nbSamples_t nb=0);
  72. virtual void DumpParams(std::vector<Testing::param_t>&);
  73. virtual Testing::param_t* ImportParams(Testing::PatternID_t,Testing::nbParameterEntries_t &,Testing::ParameterKind &);
  74. virtual bool hasParam();
  75. virtual Testing::PatternID_t getParamID();
  76. virtual void DumpPattern_f64(Testing::outputID_t,Testing::nbSamples_t nb, float64_t*);
  77. virtual void DumpPattern_f32(Testing::outputID_t,Testing::nbSamples_t nb, float32_t*);
  78. #if !defined( __CC_ARM ) && defined(ARM_FLOAT16_SUPPORTED)
  79. virtual void DumpPattern_f16(Testing::outputID_t,Testing::nbSamples_t nb, float16_t*);
  80. #endif
  81. virtual void DumpPattern_q63(Testing::outputID_t,Testing::nbSamples_t nb, q63_t*);
  82. virtual void DumpPattern_q31(Testing::outputID_t,Testing::nbSamples_t nb, q31_t*);
  83. virtual void DumpPattern_q15(Testing::outputID_t,Testing::nbSamples_t nb, q15_t*);
  84. virtual void DumpPattern_q7(Testing::outputID_t,Testing::nbSamples_t nb, q7_t*);
  85. virtual void DumpPattern_u32(Testing::outputID_t,Testing::nbSamples_t nb, uint32_t*);
  86. virtual void DumpPattern_u16(Testing::outputID_t,Testing::nbSamples_t nb, uint16_t*);
  87. virtual void DumpPattern_u8(Testing::outputID_t,Testing::nbSamples_t nb, uint8_t*);
  88. virtual Testing::testID_t CurrentTestID();
  89. private:
  90. void DeleteParams();
  91. void recomputeTestDir();
  92. // Get the path to a pattern from a pattern ID
  93. std::string getPatternPath(Testing::PatternID_t id);
  94. // Get a path to an output file from an ouput category
  95. // (test ID will be used so same output ID
  96. // is giving different names for different tests)
  97. std::string getOutputPath(Testing::outputID_t id);
  98. // Get description of parameters from parameter ID
  99. struct pathOrGen getParameterDesc(Testing::PatternID_t id);
  100. // Get file size from local path
  101. Testing::nbSamples_t GetFileSize(std::string &path);
  102. // Driver filer controlling the tests.
  103. FILE* infile;
  104. // Node description (group, suite or test)
  105. int currentKind;
  106. // Node ID
  107. Testing::testID_t currentId;
  108. // Current param ID for the node
  109. Testing::PatternID_t currentParam;
  110. bool m_hasParam;
  111. // Current path for the node
  112. // (It is not the full path but the path added by this node)
  113. std::string currentPath;
  114. // Contains the current test directory
  115. // (where to find pattenrs)
  116. std::string testDir;
  117. // Array of folder used to build the
  118. // testDir parth
  119. std::vector<std::string> *path;
  120. // Root directory for patterns
  121. std::string patternRootPath;
  122. // Root directory for output
  123. std::string outputRootPath;
  124. // Root directory for parameters
  125. std::string parameterRootPath;
  126. // List of pattern filenames
  127. // Used to find a name from a pattern ID
  128. std::vector<std::string> *patternFilenames;
  129. // List of output names
  130. // Used to find a name from an output ID
  131. std::vector<std::string> *outputNames;
  132. // List of parameters descriptions
  133. // Used to find a path or generator from a parameter ID
  134. std::vector<struct pathOrGen> *parameterNames;
  135. };
  136. }
  137. #endif