1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        ArrayMemory.h
4  * Description:  Array Memory 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 
29 #ifndef _ARRAY_MEMORY_H_
30 #define _ARRAY_MEMORY_H_
31 
32 #include "Test.h"
33 
34 namespace Client{
35 
36 // Memory is implemented as a big buffer in which
37 // we reserve blocks.
38 // Like that we can manage alignment and tails
39 class ArrayMemory:public Client::Memory
40 {
41    public:
42     ArrayMemory(char* ptr, size_t bufferLength,int aligned, bool tail);
43     ArrayMemory(char* ptr, size_t bufferLength);
44     virtual char *NewBuffer(size_t length);
45     virtual void FreeMemory();
46     virtual bool HasMemError();
47     virtual bool IsTailEmpty(char *, size_t);
48 
49    private:
50      // Pointer to C array used for memory
51      char *m_ptr;
52      // Size of C array buffer
53      size_t m_bufferLength;
54      // Alignment required for all buffers
55      // (in future may be a setting per bufer)
56      int alignSize;
57      // True if some padding must be added after buffers
58      bool tail=true;
59      // Current pointer to the memory
60      // It is where a new buffer will be allocated
61      char *m_currentPtr;
62      // Error occured
63      bool memError=false;
64 
65      size_t getTailSize();
66 };
67 }
68 
69 #endif
70