RDK Documentation (Open Sourced RDK Components)
AampIonMemorySystem.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2020 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 #ifndef AAMPIONMEMORYSYSTEM_H
21 #define AAMPIONMEMORYSYSTEM_H
22 
23 /**
24  * @file AampIonMemorySystem.h
25  * @brief Controls the ION memory for aamp
26  */
27 
28 #include "AampMemorySystem.h"
29 
30 #include <fcntl.h>
31 #include <ion/ion.h>
32 #include <linux/ion.h>
33 
34 /**
35  * @struct AampIonMemoryInterchangeBuffer
36  * @brief Stores the information on ION Memory to store data
37  */
39  uint32_t size; /**< The size of this buffer, for testing */
40  uint32_t dataSize; /**< The size of data stored in the ION memory */
41  unsigned long phyAddr; /**< The location in Physical ION memory where the data is [from ION spec] */
42 };
43 
44 /**
45  * @class AampIonMemorySystem
46  * @brief Handles ION memory storage to store data
47  */
48 
50 public:
51  /**
52  * @fn AampIonMemorySystem
53  */
55  /**
56  * @fn ~AampIonMemorySystem
57  */
58  virtual ~AampIonMemorySystem();
59 
60  /**
61  * @fn encode
62  * @param dataIn pointer to the data to encode
63  * @param dataInSz the size to encode
64  * @param out dataOut the data to send
65  * @return true if data is encoded
66  */
67  virtual bool encode(const uint8_t *dataIn, uint32_t dataInSz, std::vector<uint8_t>& dataOut) override;
68  /**
69  * @fn decode
70  * @param dataIn pointer to the data to decode
71  * @param size the size to decode
72  * @param out dataOut the data to recover
73  * @param int dataOutSz the size of the space for data to recover
74  */
75  virtual bool decode(const uint8_t* dataIn, uint32_t dataInSz, uint8_t *dataOut, uint32_t dataOutSz) override;
76 
77  /**
78  * @fn terminateEarly
79  */
80  virtual void terminateEarly() override;
81 
82 public:
84  public:
87  AampIonMemoryContext& operator=(const AampIonMemoryContext&) = delete;
89  void close();
90  bool createBuffer(size_t len);
91  bool share(int& shareFd);
92  bool phyAddr(unsigned long *addr);
93  private:
94  int fd_;
95  ion_user_handle_t handle_;
96  AampLogManager *mLogObj;
97  const int AAMP_ION_MEMORY_REGION{RTK_PHOENIX_ION_HEAP_MEDIA_MASK};
98  const int AAMP_ION_MEMORY_FLAGS{(ION_FLAG_NONCACHED | ION_FLAG_SCPUACC | ION_FLAG_HWIPACC)};
99  const int AAMP_ION_MEMORY_ALIGN{0};
100  };
101 
102  AampIonMemoryContext context_;
103 
104 };
105 
106 
107 
108 #endif /* AAMPIONMEMORYSYSTEM_H */
109 
AampIonMemorySystem::~AampIonMemorySystem
virtual ~AampIonMemorySystem()
AampIonMemorySystem distructor.
Definition: AampIonMemorySystem.cpp:43
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
AampIonMemoryInterchangeBuffer::phyAddr
unsigned long phyAddr
Definition: AampIonMemorySystem.h:41
AampIonMemoryInterchangeBuffer::size
uint32_t size
Definition: AampIonMemorySystem.h:39
AampIonMemoryInterchangeBuffer::dataSize
uint32_t dataSize
Definition: AampIonMemorySystem.h:40
AampIonMemorySystem::encode
virtual bool encode(const uint8_t *dataIn, uint32_t dataInSz, std::vector< uint8_t > &dataOut) override
Encode a block of data to send over the divide.
Definition: AampIonMemorySystem.cpp:126
AampIonMemorySystem::terminateEarly
virtual void terminateEarly() override
Call this if there's an failure external to the MS and it needs to tidy up unexpectedly.
Definition: AampIonMemorySystem.cpp:237
AampIonMemorySystem::AampIonMemoryContext
Definition: AampIonMemorySystem.h:83
AampIonMemorySystem::AampIonMemorySystem
AampIonMemorySystem(AampLogManager *logObj)
AampIonMemorySystem constructor.
Definition: AampIonMemorySystem.cpp:37
AampIonMemorySystem::decode
virtual bool decode(const uint8_t *dataIn, uint32_t dataInSz, uint8_t *dataOut, uint32_t dataOutSz) override
Decode from getting back.
Definition: AampIonMemorySystem.cpp:180
AampMemorySystem.h
Memory handler for Aamp DRM process.
AampIonMemoryInterchangeBuffer
Stores the information on ION Memory to store data.
Definition: AampIonMemorySystem.h:38
AampIonMemorySystem
Handles ION memory storage to store data.
Definition: AampIonMemorySystem.h:49
AAMPMemorySystem
Handles the operations for AAMP memory managemnts.
Definition: AampMemorySystem.h:37