X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/4452a7af2eac33dbad800bcc91f2399d62c18f53..6601e61aa18bf4f09af135ff61fc7f4771d23b06:/osfmk/vm/vm_kern.c diff --git a/osfmk/vm/vm_kern.c b/osfmk/vm/vm_kern.c index b81d47b22..d43706c8d 100644 --- a/osfmk/vm/vm_kern.c +++ b/osfmk/vm/vm_kern.c @@ -1,29 +1,23 @@ /* * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. * - * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * @APPLE_LICENSE_HEADER_START@ * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. The rights granted to you under the License - * may not be used to create, or enable the creation or redistribution of, - * unlawful or unlicensed copies of an Apple operating system, or to - * circumvent, violate, or enable the circumvention or violation of, any - * terms of an Apple operating system software license agreement. + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. * - * Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. * - * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + * @APPLE_LICENSE_HEADER_END@ */ /* * @OSF_COPYRIGHT@ @@ -139,7 +133,7 @@ kmem_alloc_contig( object = vm_object_allocate(map_size); } - kr = vm_map_find_space(map, &map_addr, map_size, map_mask, 0, &entry); + kr = vm_map_find_space(map, &map_addr, map_size, map_mask, &entry); if (KERN_SUCCESS != kr) { vm_object_deallocate(object); return kr; @@ -167,7 +161,6 @@ kmem_alloc_contig( for (i = 0; i < map_size; i += PAGE_SIZE) { m = pages; pages = NEXT_PAGE(m); - *(NEXT_PAGE_PTR(m)) = VM_PAGE_NULL; m->busy = FALSE; vm_page_insert(m, object, offset + i); } @@ -206,10 +199,6 @@ kmem_alloc_contig( * KMA_HERE *addrp is base address, else "anywhere" * KMA_NOPAGEWAIT don't wait for pages if unavailable * KMA_KOBJECT use kernel_object - * KMA_LOMEM support for 32 bit devices in a 64 bit world - * if set and a lomemory pool is available - * grab pages from it... this also implies - * KMA_NOPAGEWAIT */ kern_return_t @@ -233,12 +222,6 @@ kernel_memory_allocate( *addrp = 0; return KERN_INVALID_ARGUMENT; } - if (flags & KMA_LOMEM) { - if ( !(flags & KMA_NOPAGEWAIT) ) { - *addrp = 0; - return KERN_INVALID_ARGUMENT; - } - } map_size = vm_map_round_page(size); map_mask = (vm_map_offset_t) mask; @@ -254,11 +237,12 @@ kernel_memory_allocate( object = vm_object_allocate(map_size); } - kr = vm_map_find_space(map, &map_addr, map_size, map_mask, 0, &entry); + kr = vm_map_find_space(map, &map_addr, map_size, map_mask, &entry); if (KERN_SUCCESS != kr) { vm_object_deallocate(object); return kr; } + entry->object.vm_object = object; entry->offset = offset = (object == kernel_object) ? map_addr - VM_MIN_KERNEL_ADDRESS : 0; @@ -270,15 +254,8 @@ kernel_memory_allocate( for (i = 0; i < map_size; i += PAGE_SIZE) { vm_page_t mem; - for (;;) { - if (flags & KMA_LOMEM) - mem = vm_page_alloclo(object, offset + i); - else - mem = vm_page_alloc(object, offset + i); - - if (mem != VM_PAGE_NULL) - break; - + while (VM_PAGE_NULL == + (mem = vm_page_alloc(object, offset + i))) { if (flags & KMA_NOPAGEWAIT) { if (object == kernel_object) vm_object_page_remove(object, offset, offset + i); @@ -406,7 +383,7 @@ kmem_realloc( */ kr = vm_map_find_space(map, &newmapaddr, newmapsize, - (vm_map_offset_t) 0, 0, &newentry); + (vm_map_offset_t) 0, &newentry); if (kr != KERN_SUCCESS) { vm_object_lock(object); for(offset = oldmapsize; @@ -740,24 +717,25 @@ kmem_init( map_end = vm_map_round_page(end); kernel_map = vm_map_create(pmap_kernel(),VM_MIN_KERNEL_ADDRESS, - map_end, FALSE); + map_end, FALSE); + /* * Reserve virtual memory allocated up to this time. */ if (start != VM_MIN_KERNEL_ADDRESS) { vm_map_offset_t map_addr; - + map_addr = VM_MIN_KERNEL_ADDRESS; (void) vm_map_enter(kernel_map, - &map_addr, - (vm_map_size_t)(map_start - VM_MIN_KERNEL_ADDRESS), - (vm_map_offset_t) 0, - VM_FLAGS_ANYWHERE | VM_FLAGS_NO_PMAP_CHECK, - VM_OBJECT_NULL, - (vm_object_offset_t) 0, FALSE, - VM_PROT_NONE, VM_PROT_NONE, - VM_INHERIT_DEFAULT); + &map_addr, + (vm_map_size_t)(map_start - VM_MIN_KERNEL_ADDRESS), + (vm_map_offset_t) 0, + VM_FLAGS_ANYWHERE | VM_FLAGS_NO_PMAP_CHECK, + VM_OBJECT_NULL, + (vm_object_offset_t) 0, FALSE, + VM_PROT_DEFAULT, VM_PROT_ALL, + VM_INHERIT_DEFAULT); } /*