OLD | NEW |
1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #include "platforms/stm/disco_fletch/src/page_allocator.h" | 5 #include "platforms/stm/disco_dartino/src/page_allocator.h" |
6 | 6 |
7 #include "src/shared/assert.h" | 7 #include "src/shared/assert.h" |
8 | 8 |
9 uint32_t PageAllocator::AddArena(const char* name, uintptr_t start, | 9 uint32_t PageAllocator::AddArena(const char* name, uintptr_t start, |
10 size_t size, uint8_t* map, size_t map_size) { | 10 size_t size, uint8_t* map, size_t map_size) { |
11 for (int i = 0; i < kMaxArenas; i++) { | 11 for (int i = 0; i < kMaxArenas; i++) { |
12 if (arenas_[i].IsFree()) { | 12 if (arenas_[i].IsFree()) { |
13 arenas_[i].Initialize(name, start, size, map, map_size); | 13 arenas_[i].Initialize(name, start, size, map, map_size); |
14 return 1 << i; | 14 return 1 << i; |
15 } | 15 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 return NULL; | 81 return NULL; |
82 } | 82 } |
83 | 83 |
84 void PageAllocator::Arena::FreePages(void* start, size_t pages) { | 84 void PageAllocator::Arena::FreePages(void* start, size_t pages) { |
85 size_t index = (reinterpret_cast<uint8_t*>(start) - base_) >> PAGE_SIZE_SHIFT; | 85 size_t index = (reinterpret_cast<uint8_t*>(start) - base_) >> PAGE_SIZE_SHIFT; |
86 for (int i = 0; i < pages; i++) { | 86 for (int i = 0; i < pages; i++) { |
87 ASSERT(map_[index + i] != 0); | 87 ASSERT(map_[index + i] != 0); |
88 map_[index + i] = 0; | 88 map_[index + i] = 0; |
89 } | 89 } |
90 } | 90 } |
OLD | NEW |