From 19b83dc2b30d1727a02e1a175ad52d8620cf4b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 19 Jan 2005 03:17:25 +0000 Subject: [PATCH] Got rid of ERR_VM_NO_REGION_SLOT - we now return BeBook friendly error codes. Added short description to find_reserved_area() as that name is not that good. vm_reserve_address_range() now doesn't do anything if the requested size of the reservation is zero. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10867 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/vm/vm.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/kernel/core/vm/vm.c b/src/kernel/core/vm/vm.c index e2f2293422..176f48e11f 100755 --- a/src/kernel/core/vm/vm.c +++ b/src/kernel/core/vm/vm.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2002-2005, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -175,6 +175,11 @@ _vm_create_area_struct(vm_address_space *aspace, const char *name, uint32 wiring } +/** Finds a reserved area that covers the region spanned by \a start and + * \a size, inserts the \a area into that region and makes sure that + * there are reserved regions for the remaining parts. + */ + static status_t find_reserved_area(vm_virtual_map *map, addr_t start, addr_t size, vm_area *area) { @@ -186,7 +191,7 @@ find_reserved_area(vm_virtual_map *map, addr_t start, addr_t size, vm_area *area // this area covers the requested range if (next->id != RESERVED_REGION_ID) { // but it's not reserved space, it's a real area - return ERR_VM_NO_REGION_SLOT; + return B_BAD_VALUE; } break; @@ -272,7 +277,7 @@ find_and_insert_area_slot(vm_virtual_map *map, addr_t start, addr_t size, addr_t if (addressSpec == B_EXACT_ADDRESS) { // search for a reserved area status_t status = find_reserved_area(map, start, size, area); - if (status == B_OK || status == ERR_VM_NO_REGION_SLOT) + if (status == B_OK || status == B_BAD_VALUE) return status; // there was no reserved area, and the slot doesn't seem to be used already @@ -390,7 +395,7 @@ second_chance: } if (!foundspot) - return ERR_VM_NO_REGION_SLOT; + return addressSpec == B_EXACT_ADDRESS ? B_BAD_VALUE : B_NO_MEMORY; area->size = size; if (last) { @@ -619,6 +624,9 @@ vm_reserve_address_range(aspace_id aid, void **_address, uint32 addressSpec, add vm_area *area; status_t status = B_OK; + if (size == 0) + return B_BAD_VALUE; + addressSpace = vm_get_aspace_by_id(aid); if (addressSpace == NULL) return ERR_VM_INVALID_ASPACE;