CMemorySegment.h
3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//=========================================================
//
// Class Name: CMemorySegment
// Author:
// Company: VAutomation An Arc Cores Company
// Date created: 3/20/2002 at 10:22
//
//
//==========================================================
//
// No notes.
//
//
//
//==========================================================
#ifndef __CMEMORYSEGMENT__
#define __CMEMORYSEGMENT__
//=========================================================
// Member Varible Includes
//=========================================================
//=========================================================
// HEADER INCLUDE FILE SECTION
//=========================================================
#include "DataTypes.h"
#include "SystemAccess.h"
#include "MessageIO.h"
//=========================================================
// TYPES
//=========================================================
//=========================================================
// Constants
//=========================================================
const UnSignedLong DefaultMaxCacheSizeInBytes = 256;
//=========================================================
//
// Class Comments:
//
// This class is designed to keep track of the memory when attempting
// to get aligned memory.
//
//
// Public function comments:
//
// Create:
// This function will allocate a segment of memory on a byte boundary and set the init value.
//
// Address:
// Returns the address of the first working byte of the aligned segment
//
//
// Private function comments:
//
//
// Protected function comments:
//
//
//=========================================================
class CMemorySegment
{
public:
// Member functions
bool Create
( const UnSignedLong working_data_bytes, // Number of bytes for data access
const UnSignedLong alignment_boundary, // The byte boundary required for this segment
const unsigned char init_value = 0 // The init value of the memory
); // Return Value: Success of this operation.
bool PrintWorkingDataBytes( CMessageIO& g_message_interface );
volatile AddressType GetWorkingAddress
( ) const; // Return Value: Pointer to the address of the first working byte in the segment
// Member functions default overrides
CMemorySegment( ); // Default constructor
virtual ~CMemorySegment( ); // Destructor
CMemorySegment( const CMemorySegment &cmemorysegment_item ); // Copy constructor
// Operator Members
CMemorySegment& operator = ( const CMemorySegment &cmemorysegment_item );
bool operator == ( const CMemorySegment &cmemorysegment_item ) const;
// GetCopy Member Functions
UnSignedLong GetCopyWorkingByteSize( void ) const;
UnSignedLong GetCopyTrueByteSize( void ) const;
// Set Member Functions
bool SetWorkingAddressForAccessOnly( volatile AddressType access_only_address );
public:
// Member varibles
private:
// Member functions
private:
// Member varibles
volatile unsigned char *m_true_heap_start_address; //Keeps the start address in the heap segment
volatile unsigned char *m_working_start_address; //Keeps the first address of the working memory
UnSignedLong m_working_byte_size; //The number of bytes in the working area of the segment
UnSignedLong m_true_byte_size; //The number of bytes allocated in the heap
UnSignedLong m_alignment_boundary; //The bound the working memory is aligned to
protected:
// Member functions
void CopyDataToThis( const CMemorySegment &cmemorysegment_item ); //Class copy internal data.
protected:
// Member varibles
public:
// Friend functions
};
#endif
//=========================================================