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