X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/55e303ae13a4cf49d70f2294092726f2fffb9ef2..b7266188b87f3620ec3f9f717e57194a7dd989fe:/osfmk/ppc/savearea.c diff --git a/osfmk/ppc/savearea.c b/osfmk/ppc/savearea.c index c82affcef..0e95c5ff1 100644 --- a/osfmk/ppc/savearea.c +++ b/osfmk/ppc/savearea.c @@ -1,16 +1,19 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ - * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * @APPLE_OSREFERENCE_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. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * 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. + * + * 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 @@ -20,14 +23,13 @@ * Please see the License for the specific language governing rights and * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * This file is used to maintain the exception save areas * */ -#include #include #include #include @@ -54,7 +56,6 @@ #include -extern struct Saveanchor saveanchor; /* Aliged savearea anchor */ struct Saveanchor backpocket; /* Emergency saveareas */ unsigned int debsave0 = 0; /* Debug flag */ unsigned int backchain = 0; /* Debug flag */ @@ -135,7 +136,7 @@ void savearea_init(vm_offset_t addr) { savearea_comm *savec; vm_offset_t save; - int i; + unsigned int i; saveanchor.savetarget = InitialSaveTarget; /* Initial target value */ @@ -143,8 +144,8 @@ void savearea_init(vm_offset_t addr) { saveanchor.savefree = 0; /* Remember the start of the free chain */ saveanchor.savefreecnt = 0; /* Remember the length */ - saveanchor.savepoolfwd = (addr64_t)&saveanchor; /* Remember pool forward */ - saveanchor.savepoolbwd = (addr64_t)&saveanchor; /* Remember pool backward */ + saveanchor.savepoolfwd = (addr64_t)(uintptr_t)&saveanchor; /* Remember pool forward */ + saveanchor.savepoolbwd = (addr64_t)(uintptr_t)&saveanchor; /* Remember pool backward */ save = addr; /* Point to the whole block of blocks */ @@ -178,8 +179,8 @@ void savearea_init(vm_offset_t addr) { saveanchor.savefree = 0; /* Remember the start of the free chain */ saveanchor.savefreecnt = 0; /* Remember the length */ saveanchor.saveadjust = 0; /* Set none needed yet */ - saveanchor.savepoolfwd = (addr64_t)&saveanchor; /* Remember pool forward */ - saveanchor.savepoolbwd = (addr64_t)&saveanchor; /* Remember pool backward */ + saveanchor.savepoolfwd = (addr64_t)(uintptr_t)&saveanchor; /* Remember pool forward */ + saveanchor.savepoolbwd = (addr64_t)(uintptr_t)&saveanchor; /* Remember pool backward */ for(i=0; i < InitialSaveBloks; i++) { /* Initialize the saveareas */ @@ -207,12 +208,12 @@ void savearea_init(vm_offset_t addr) { /* * This will populate the local list and get the first one for the system */ - per_proc_info[0].next_savearea = (vm_offset_t)save_get(); + /* XXX next_savearea should be a void * 4425541 */ + getPerProc()->next_savearea = (unsigned long)(void *)save_get(); /* * The system is now able to take interruptions */ - return; } @@ -233,23 +234,22 @@ struct savearea *save_alloc(void) { /* Reserve a save area */ /* - * This routine releases a save area to the free queue. If after that, we have more than our maximum target, - * we start releasing what we can until we hit the normal target. + * This routine releases a save area to the free queue. If after that, + * we have more than our maximum target, we start releasing what we can + * until we hit the normal target. */ +void +save_release(struct savearea *save) +{ + /* Return a savearea to the free list */ + save_ret(save); - -void save_release(struct savearea *save) { /* Release a save area */ - - save_ret(save); /* Return a savearea to the free list */ - - if(saveanchor.saveadjust) save_adjust(); /* Adjust the savearea free list and pool size if needed */ - - return; - + /* Adjust the savearea free list and pool size if needed */ + if(saveanchor.saveadjust) + save_adjust(); } - /* * Adjusts the size of the free list. Can either release or allocate full pages * of kernel memory. This can block. @@ -269,7 +269,6 @@ void save_adjust(void) { savearea_comm *sctl, *sctlnext, *freepage; kern_return_t ret; - uint64_t vtopmask; ppnum_t physpage; if(saveanchor.saveadjust < 0) { /* Do we need to adjust down? */ @@ -288,14 +287,14 @@ void save_adjust(void) { while(saveanchor.saveadjust > 0) { /* Keep going until we have enough */ - ret = kmem_alloc_wired(kernel_map, (vm_offset_t *)&freepage, PAGE_SIZE); /* Get a page for free pool */ + ret = kmem_alloc_kobject(kernel_map, (vm_offset_t *)&freepage, PAGE_SIZE); /* Get a page for free pool */ if(ret != KERN_SUCCESS) { /* Did we get some memory? */ panic("Whoops... Not a bit of wired memory left for saveareas\n"); } physpage = pmap_find_phys(kernel_pmap, (vm_offset_t)freepage); /* Find physical page */ if(!physpage) { /* See if we actually have this mapped*/ - panic("save_adjust: wired page not mapped - va = %08X\n", freepage); /* Die */ + panic("save_adjust: wired page not mapped - va = %p\n", freepage); /* Die */ } bzero((void *)freepage, PAGE_SIZE); /* Clear it all to zeros */ @@ -312,14 +311,14 @@ void save_adjust(void) { /* * Fake up information to make the saveareas look like a zone */ - +void save_fake_zone_info(int *count, vm_size_t *cur_size, vm_size_t *max_size, vm_size_t *elem_size, vm_size_t *alloc_size, int *collectable, int *exhaustable) { *count = saveanchor.saveinuse; *cur_size = (saveanchor.savefreecnt + saveanchor.saveinuse) * (PAGE_SIZE / sac_cnt); *max_size = saveanchor.savemaxcount * (PAGE_SIZE / sac_cnt); - *elem_size = sizeof(savearea); + *elem_size = sizeof(struct savearea); *alloc_size = PAGE_SIZE; *collectable = 1; *exhaustable = 0;