OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(HOST_OS_FUCHSIA) | 6 #if defined(HOST_OS_FUCHSIA) |
7 | 7 |
8 #include "vm/virtual_memory.h" | 8 #include "vm/virtual_memory.h" |
9 | 9 |
10 #include <magenta/process.h> | 10 #include <magenta/process.h> |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 mx_status_t status = | 194 mx_status_t status = |
195 mx_vmar_unmap(vmar, reinterpret_cast<uintptr_t>(address), size); | 195 mx_vmar_unmap(vmar, reinterpret_cast<uintptr_t>(address), size); |
196 if (status != MX_OK) { | 196 if (status != MX_OK) { |
197 LOG_ERR("mx_vmar_unmap failed: %s\n", mx_status_get_string(status)); | 197 LOG_ERR("mx_vmar_unmap failed: %s\n", mx_status_get_string(status)); |
198 return false; | 198 return false; |
199 } | 199 } |
200 return true; | 200 return true; |
201 } | 201 } |
202 | 202 |
203 | 203 |
204 bool VirtualMemory::Commit(uword addr, intptr_t size, bool executable) { | 204 bool VirtualMemory::Commit(uword addr, |
| 205 intptr_t size, |
| 206 bool executable, |
| 207 const char* name) { |
205 ASSERT(Contains(addr)); | 208 ASSERT(Contains(addr)); |
206 ASSERT(Contains(addr + size) || (addr + size == end())); | 209 ASSERT(Contains(addr + size) || (addr + size == end())); |
207 mx_handle_t vmo = MX_HANDLE_INVALID; | 210 mx_handle_t vmo = MX_HANDLE_INVALID; |
208 mx_status_t status = mx_vmo_create(size, 0u, &vmo); | 211 mx_status_t status = mx_vmo_create(size, 0u, &vmo); |
209 if (status != MX_OK) { | 212 if (status != MX_OK) { |
210 LOG_ERR("mx_vmo_create(%ld) failed: %s\n", size, | 213 LOG_ERR("mx_vmo_create(%ld) failed: %s\n", size, |
211 mx_status_get_string(status)); | 214 mx_status_get_string(status)); |
212 return false; | 215 return false; |
213 } | 216 } |
214 | 217 |
| 218 if (name != NULL) { |
| 219 mx_object_set_property(vmo, MX_PROP_NAME, name, strlen(name)); |
| 220 } |
| 221 |
215 mx_handle_t vmar = static_cast<mx_handle_t>(handle()); | 222 mx_handle_t vmar = static_cast<mx_handle_t>(handle()); |
216 const size_t offset = addr - start(); | 223 const size_t offset = addr - start(); |
217 const uint32_t flags = MX_VM_FLAG_SPECIFIC | MX_VM_FLAG_PERM_READ | | 224 const uint32_t flags = MX_VM_FLAG_SPECIFIC | MX_VM_FLAG_PERM_READ | |
218 MX_VM_FLAG_PERM_WRITE | | 225 MX_VM_FLAG_PERM_WRITE | |
219 (executable ? MX_VM_FLAG_PERM_EXECUTE : 0); | 226 (executable ? MX_VM_FLAG_PERM_EXECUTE : 0); |
220 uintptr_t mapped_addr; | 227 uintptr_t mapped_addr; |
221 status = mx_vmar_map(vmar, offset, vmo, 0, size, flags, &mapped_addr); | 228 status = mx_vmar_map(vmar, offset, vmo, 0, size, flags, &mapped_addr); |
222 if (status != MX_OK) { | 229 if (status != MX_OK) { |
223 mx_handle_close(vmo); | 230 mx_handle_close(vmo); |
224 LOG_ERR("mx_vmar_map(%ld, %ld, %u) failed: %s\n", offset, size, flags, | 231 LOG_ERR("mx_vmar_map(%ld, %ld, %u) failed: %s\n", offset, size, flags, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 return false; | 281 return false; |
275 } | 282 } |
276 LOG_INFO("mx_vmar_protect(%lx, %lx, %x) success\n", page_address, | 283 LOG_INFO("mx_vmar_protect(%lx, %lx, %x) success\n", page_address, |
277 end_address - page_address, prot); | 284 end_address - page_address, prot); |
278 return true; | 285 return true; |
279 } | 286 } |
280 | 287 |
281 } // namespace dart | 288 } // namespace dart |
282 | 289 |
283 #endif // defined(HOST_OS_FUCHSIA) | 290 #endif // defined(HOST_OS_FUCHSIA) |
OLD | NEW |