Home | History | Annotate | Download | only in quipper

Lines Matching defs:range

19 struct Range {
25 Range() : addr(0), size(0), id(0), base_offset(0) {}
27 Range(uint64_t addr, uint64_t size, uint64_t id, uint64_t base_offset)
37 const Range kMapRanges[] = {
38 Range(0xff000000, 0x100000, 0xdeadbeef, 0),
39 Range(0x00a00000, 0x10000, 0xcafebabe, 0),
40 Range(0x0c000000, 0x1000000, 0x900df00d, 0),
41 Range(0x00001000, 0x30000, 0x9000091e, 0),
51 // Number of regularly-spaced intervals within a mapped range to test.
56 uint64_t GetMappedAddressFromRanges(const Range* ranges,
63 const Range& range = ranges[i];
64 if (range.contains(addr)) return (addr - range.addr) + mapped_range_addr;
80 // Maps a range using the AddressMapper and makes sure that it was successful.
81 // Uses all fields of |range|, including id and base_offset.
82 bool MapRange(const Range& range, bool remove_old_mappings) {
83 VLOG(1) << "Mapping range at " << std::hex << range.addr
84 << " with length of " << range.size << " and id " << range.id;
85 return mapper_->MapWithID(range.addr, range.size, range.id,
86 range.base_offset, remove_old_mappings);
89 // Tests a range that has been mapped. |expected_mapped_addr| is the starting
91 // and end addresses of the range, as well as a bunch of addresses inside it.
93 void TestMappedRange(const Range& range, uint64_t expected_mapped_addr) {
97 VLOG(1) << "Testing range at " << std::hex << range.addr
98 << " with length of " << std::hex << range.size;
100 // Check address at the beginning of the range and at subsequent intervals.
102 const uint64_t offset = i * (range.size / kNumRangeTestIntervals);
103 uint64_t addr = range.addr + offset;
112 EXPECT_EQ(range.base_offset + offset, mapped_offset);
113 EXPECT_EQ(range.id, mapped_id);
116 // Check address at end of the range.
118 range.addr + range.size - 1, &mapped_addr, &addr_iter));
119 EXPECT_EQ(expected_mapped_addr + range.size - 1, mapped_addr);
125 // Map one range at a time and test looking up addresses.
127 for (const Range& range : kMapRanges) {
129 ASSERT_TRUE(MapRange(range, false));
131 TestMappedRange(range, 0);
133 // Check addresses before the mapped range, should be invalid.
136 EXPECT_FALSE(mapper_->GetMappedAddressAndListIterator(range.addr - 1,
138 EXPECT_FALSE(mapper_->GetMappedAddressAndListIterator(range.addr - 0x100,
141 range.addr + range.size, &mapped_addr, &iter));
143 range.addr + range.size + 0x100, &mapped_addr, &iter));
144 EXPECT_EQ(range.size, mapper_->GetMaxMappedLength());
151 for (const Range& range : kMapRanges) {
152 ASSERT_TRUE(MapRange(range, false));
153 size_mapped += range.size;
160 // For each mapped range, test addresses at the start, middle, and end.
161 // Also test the address right before and after each range.
164 for (const Range& range : kMapRanges) {
165 TestMappedRange(range, GetMappedAddressFromRanges(
166 kMapRanges, arraysize(kMapRanges), range.addr));
168 // Check addresses before and after the mapped range, should be invalid.
169 EXPECT_FALSE(mapper_->GetMappedAddressAndListIterator(range.addr - 1,
171 EXPECT_FALSE(mapper_->GetMappedAddressAndListIterator(range.addr - 0x100,
174 range.addr + range.size, &mapped_addr, &iter));
176 range.addr + range.size + 0x100, &mapped_addr, &iter));
188 for (const Range& range : kMapRanges) {
189 LOG(INFO) << "Mapping range at " << std::hex << range.addr
190 << " with length of " << std::hex << range.size;
191 ASSERT_TRUE(mapper_->MapWithID(range.addr, range.size, range.id, 0, false));
195 // For each mapped range, test addresses at the start, middle, and end.
196 // Also test the address right before and after each range.
197 for (const Range& range : kMapRanges) {
198 TestMappedRange(range, GetMappedAddressFromRanges(
199 kMapRanges, arraysize(kMapRanges), range.addr));
206 for (const Range& range : kMapRanges) ASSERT_TRUE(MapRange(range, false));
208 // Attempt to re-map each range, but offset by size / 2.
209 for (const Range& range : kMapRanges) {
210 Range new_range;
211 new_range.addr = range.addr + range.size / 2;
212 new_range.size = range.size;
217 // Re-map each range with the same offset. Only this time, remove any old
218 // mapped range that overlaps with it.
219 for (const Range& range : kMapRanges) {
220 Range new_range;
221 new_range.addr = range.addr + range.size / 2;
222 new_range.size = range.size;
227 // The range is shifted in real space but should still be the same in
231 range.addr));
238 const Range kBigRegion(0xa00, 0xff000000, 0x1234, 0);
241 for (const Range& range : kMapRanges) ASSERT_TRUE(MapRange(range, false));
269 for (const Range& range : kMapRanges) {
270 for (uint64_t addr = range.addr; addr < range.addr + range.size;
271 addr += range.size / kNumRangeTestIntervals) {
291 const Range kEndRegion(0xffffffff00000000, 0x100000000, 0x3456, 0);
302 const Range kOutOfBoundsRegion(0xffffffff00000000, 0x00000000, 0xccddeeff, 0);
317 const Range kFullRegion(0, UINT64_MAX, 0xaabbccdd, 0);
326 for (const Range& range : kMapRanges) {
328 ASSERT_FALSE(MapRange(range, false));
329 ASSERT_TRUE(MapRange(range, true));
332 // should have split an existing range.
338 // Test mapping of one range in the middle of an existing range. The existing
339 // range should be split into two to accommodate it. Also tests the use of base
343 const Range kFirstRange(0x10000, 0x4000, 0x11223344, 0x5000);
344 const Range kSecondRange(0x12000, 0x1000, 0x55667788, 0);
346 // As a sanity check, make sure the second range is fully contained within the
347 // first range.
356 // The first range should have been split into two parts to make way for the
357 // second range. There should be a total of three ranges.
362 // The first range has been split up. Define the expected ranges here.
363 const Range kFirstRangeHead(0x10000, 0x2000, kFirstRange.id, 0x5000);
364 const Range kFirstRangeTail(0x13000, 0x1000, kFirstRange.id, 0x8000);
366 // Test the two remaining parts of the first range.
370 // Test the second range normally.
379 const Range kUnalignedRanges[] = {
380 Range(0xff000100, 0x1fff00, 0xdeadbeef, 0x100),
381 Range(0x00a00180, 0x10000, 0xcafebabe, 0x180),
382 Range(0x0c000300, 0x1000800, 0x900df00d, 0x4300),
383 Range(0x000017f0, 0x30000, 0x9000091e, 0x7f0),
387 for (const Range& range : kUnalignedRanges)
388 ASSERT_TRUE(MapRange(range, true));
417 const Range kRange0(0x3000, 0x8000, 0xdeadbeef, 0);
418 const Range kRange1(0x5000, 0x2000, 0xfeedbabe, 0);
426 const Range kRange0Head(0x3000, 0x2000, 0xdeadbeef, 0);
427 const Range kRange0Tail(0x7000, 0x4000, 0xdeadbeef, 0x4000);
440 const Range kRange0(0x3000, 0x8000, 0xdeadbeef, 0);
441 const Range kMisalignedRange(0x4800, 0x2000, 0xfeedbabe, 0);
445 // range. It is not allowed to move the existing mapping.