physical.cc (9386:b08ec9cf2e3f) physical.cc (9404:c194718a592c)
1/*
2 * Copyright (c) 2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 81 unchanged lines hidden (view full) ---

90 // memories are allowed to overlap in the logic address
91 // map
92 vector<AbstractMemory*> unmapped_mems;
93 unmapped_mems.push_back(*m);
94 createBackingStore((*m)->getAddrRange(), unmapped_mems);
95 }
96 }
97
1/*
2 * Copyright (c) 2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 81 unchanged lines hidden (view full) ---

90 // memories are allowed to overlap in the logic address
91 // map
92 vector<AbstractMemory*> unmapped_mems;
93 unmapped_mems.push_back(*m);
94 createBackingStore((*m)->getAddrRange(), unmapped_mems);
95 }
96 }
97
98 // iterate over the increasing addresses and create as large
99 // chunks as possible of contigous space to be mapped to backing
100 // store, also remember what memories constitute the range so we
101 // can go and find out if we have to init their parts to zero
102 AddrRange curr_range;
98 // iterate over the increasing addresses and chunks of contigous
99 // space to be mapped to backing store, also remember what
100 // memories constitute the range so we can go and find out if we
101 // have to init their parts to zero
103 vector<AbstractMemory*> curr_memories;
104 for (AddrRangeMap<AbstractMemory*>::const_iterator r = addrMap.begin();
105 r != addrMap.end(); ++r) {
106 // simply skip past all memories that are null and hence do
107 // not need any backing store
108 if (!r->second->isNull()) {
102 vector<AbstractMemory*> curr_memories;
103 for (AddrRangeMap<AbstractMemory*>::const_iterator r = addrMap.begin();
104 r != addrMap.end(); ++r) {
105 // simply skip past all memories that are null and hence do
106 // not need any backing store
107 if (!r->second->isNull()) {
109 // if the current range is valid, decide if we split or
110 // not
111 if (curr_range.valid()) {
112 // if the ranges are neighbours, then append, this
113 // will eventually be extended to include support for
114 // address striping and merge the interleaved ranges
115 if (curr_range.end + 1 == r->first.start) {
116 DPRINTF(BusAddrRanges,
117 "Merging neighbouring ranges %x:%x and %x:%x\n",
118 curr_range.start, curr_range.end, r->first.start,
119 r->first.end);
120 // update the end of the range and add the current
121 // memory to the list of memories
122 curr_range.end = r->first.end;
123 curr_memories.push_back(r->second);
124 } else {
125 // what we already have is valid, and this is not
126 // contigious, so create the backing store and
127 // then start over
128 createBackingStore(curr_range, curr_memories);
129
130 // remember the current range and reset the current
131 // set of memories to contain this one
132 curr_range = r->first;
133 curr_memories.clear();
134 curr_memories.push_back(r->second);
135 }
136 } else {
137 // we haven't seen any valid ranges yet, so remember
138 // the current range and reset the current set of
139 // memories to contain this one
140 curr_range = r->first;
141 curr_memories.clear();
142 curr_memories.push_back(r->second);
143 }
108 // this will eventually be extended to support merging of
109 // interleaved address ranges, and although it might seem
110 // overly complicated at this point it will all be used
111 curr_memories.push_back(r->second);
112 createBackingStore(r->first, curr_memories);
113 curr_memories.clear();
144 }
145 }
114 }
115 }
146
147 // if we have a valid range upon finishing the iteration, then
148 // create the backing store
149 if (curr_range.valid())
150 createBackingStore(curr_range, curr_memories);
151}
152
153void
154PhysicalMemory::createBackingStore(AddrRange range,
155 const vector<AbstractMemory*>& _memories)
156{
157 // perform the actual mmap
158 DPRINTF(BusAddrRanges, "Creating backing store for range %x:%x\n",

--- 8 unchanged lines hidden (view full) ---

167 fatal("Could not mmap %d bytes for range %x:%x!\n", range.size(),
168 range.start, range.end);
169 }
170
171 // remember this backing store so we can checkpoint it and unmap
172 // it appropriately
173 backingStore.push_back(make_pair(range, pmem));
174
116}
117
118void
119PhysicalMemory::createBackingStore(AddrRange range,
120 const vector<AbstractMemory*>& _memories)
121{
122 // perform the actual mmap
123 DPRINTF(BusAddrRanges, "Creating backing store for range %x:%x\n",

--- 8 unchanged lines hidden (view full) ---

132 fatal("Could not mmap %d bytes for range %x:%x!\n", range.size(),
133 range.start, range.end);
134 }
135
136 // remember this backing store so we can checkpoint it and unmap
137 // it appropriately
138 backingStore.push_back(make_pair(range, pmem));
139
140 // count how many of the memories are to be zero initialized so we
141 // can see if some but not all have this parameter set
142 uint32_t init_to_zero = 0;
143
175 // point the memories to their backing store, and if requested,
176 // initialize the memory range to 0
177 for (vector<AbstractMemory*>::const_iterator m = _memories.begin();
178 m != _memories.end(); ++m) {
179 DPRINTF(BusAddrRanges, "Mapping memory %s to backing store\n",
180 (*m)->name());
181 (*m)->setBackingStore(pmem);
182
183 // if it should be zero, then go and make it so
144 // point the memories to their backing store, and if requested,
145 // initialize the memory range to 0
146 for (vector<AbstractMemory*>::const_iterator m = _memories.begin();
147 m != _memories.end(); ++m) {
148 DPRINTF(BusAddrRanges, "Mapping memory %s to backing store\n",
149 (*m)->name());
150 (*m)->setBackingStore(pmem);
151
152 // if it should be zero, then go and make it so
184 if ((*m)->initToZero())
185 memset(pmem, 0, (*m)->size());
153 if ((*m)->initToZero()) {
154 ++init_to_zero;
155 }
156 }
186
157
187 // advance the pointer for the next memory in line
188 pmem += (*m)->size();
158 if (init_to_zero != 0) {
159 if (init_to_zero != _memories.size())
160 fatal("Some, but not all memories in range %x:%x are set zero\n",
161 range.start, range.end);
162
163 memset(pmem, 0, range.size());
189 }
190}
191
192PhysicalMemory::~PhysicalMemory()
193{
194 // unmap the backing store
195 for (vector<pair<AddrRange, uint8_t*> >::iterator s = backingStore.begin();
196 s != backingStore.end(); ++s)

--- 248 unchanged lines hidden ---
164 }
165}
166
167PhysicalMemory::~PhysicalMemory()
168{
169 // unmap the backing store
170 for (vector<pair<AddrRange, uint8_t*> >::iterator s = backingStore.begin();
171 s != backingStore.end(); ++s)

--- 248 unchanged lines hidden ---