ArrayMemory.h 2.0 KB

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