X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/a3d08fcd5120d2aa8303b6349ca8b14e3f284af3..4a3eedf9ecc9bbe3f3a5c6ce5e53ad199d639d32:/osfmk/ppc/savearea.h?ds=sidebyside diff --git a/osfmk/ppc/savearea.h b/osfmk/ppc/savearea.h index 0cec372ef..496591cb6 100644 --- a/osfmk/ppc/savearea.h +++ b/osfmk/ppc/savearea.h @@ -1,24 +1,32 @@ /* - * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2007 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * 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. + * 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. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * 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 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * 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. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ +#ifdef XNU_KERNEL_PRIVATE + #ifndef _PPC_SAVEAREA_H_ #define _PPC_SAVEAREA_H_ @@ -28,7 +36,7 @@ #ifdef __APPLE_API_PRIVATE -#ifdef MACH_KERNEL_PRIVATE +#if defined(MACH_KERNEL_PRIVATE) || defined(BSD_KERNEL_PRIVATE) #include #include @@ -57,7 +65,7 @@ typedef struct savearea_comm { /* 0x20 */ unsigned int save_time[2]; /* Context save time - for debugging or performance */ - struct thread_activation *save_act; /* Associated activation */ + struct thread *save_act; /* Associated thread */ unsigned int save_02c; uint64_t sac_vrswap; /* XOR mask to swap V to R or vice versa */ unsigned int save_flags; /* Various flags */ @@ -65,7 +73,7 @@ typedef struct savearea_comm { /* offset 0x040 */ uint64_t save_misc0; /* Various stuff */ - uint64_t save_misc1; /* Various stuff */ + uint64_t save_misc1; /* Various stuff - snapshot chain during hibernation */ unsigned int sac_alloc; /* Bitmap of allocated slots */ unsigned int save_054; unsigned int save_misc2; @@ -74,15 +82,7 @@ typedef struct savearea_comm { /* offset 0x0060 */ } savearea_comm; #pragma pack() -#endif -#ifdef BSD_KERNEL_PRIVATE -typedef struct savearea_comm { - unsigned int save_000[24]; -} savearea_comm; -#endif - -#if defined(MACH_KERNEL_PRIVATE) || defined(BSD_KERNEL_PRIVATE) /* * This type of savearea contains all of the general context. */ @@ -96,7 +96,6 @@ typedef struct savearea { uint64_t save_xdat1; /* Exception data 1 */ uint64_t save_xdat2; /* Exception data 2 */ uint64_t save_xdat3; /* Exception data 3 */ - /* offset 0x0080 */ uint64_t save_r0; uint64_t save_r1; @@ -164,9 +163,9 @@ typedef struct savearea { unsigned int save_238[2]; /* offset 0x240 */ - unsigned int save_instr[16]; /* Instrumentation */ + unsigned int save_instr[16]; /* Instrumentation or emulation. Note: save_instr[0] is number of instructions */ /* offset 0x280 */ -} savearea; +} savearea_t; #pragma pack() @@ -309,16 +308,17 @@ struct Saveanchor { volatile unsigned int savefreecnt; /* 020 Number of saveareas on global free list */ volatile int saveadjust; /* 024 If 0 number of saveareas is ok, otherwise # to change (pos means grow, neg means shrink */ volatile int saveinuse; /* 028 Number of areas in use counting those on the local free list */ - volatile int savetarget; /* 02C Number of savearea's needed */ + unsigned int savetarget; /* 02C Number of saveareas needed */ int savemaxcount; /* 030 Maximum saveareas ever allocated */ - unsigned int saveRSVD034[3]; /* 034 reserved */ + unsigned int saveinusesnapshot; /* 034 snapshot inuse count */ + volatile addr64_t savefreesnapshot; /* 038 snapshot global free list header */ /* 040 */ - }; #pragma pack() +extern struct Saveanchor saveanchor; /* Aliged savearea anchor */ -#define sac_cnt (4096 / sizeof(savearea)) /* Number of saveareas per page */ +#define sac_cnt (4096 / sizeof(struct savearea)) /* Number of saveareas per page */ #define sac_empty (0xFFFFFFFF << (32 - sac_cnt)) /* Mask with all entries empty */ #define sac_perm 0x40000000 /* Page permanently assigned */ #define sac_permb 1 /* Page permanently assigned - bit position */ @@ -327,11 +327,11 @@ struct Saveanchor { #define LocalSaveMin (LocalSaveTarget / 2) /* Min size of local savearea free list before we grow */ #define LocalSaveMax (LocalSaveTarget * 2) /* Max size of local savearea free list before we trim */ -#define FreeListMin (2 * LocalSaveTarget * NCPUS) /* Always make sure there are enough to fill local list twice per processor */ -#define SaveLowHysteresis LocalSaveTarget /* The number off from target before we adjust upwards */ -#define SaveHighHysteresis FreeListMin /* The number off from target before we adjust downwards */ +#define FreeListMin (2 * LocalSaveTarget) /* Always make sure there are enough to fill local list twice per processor */ +#define SaveLowHysteresis LocalSaveTarget /* The number off from target before we adjust upwards */ +#define SaveHighHysteresis (2 * FreeListMin) /* The number off from target before we adjust downwards */ #define InitialSaveAreas (2 * FreeListMin) /* The number of saveareas to make at boot time */ -#define InitialSaveTarget FreeListMin /* The number of saveareas for an initial target. This should be the minimum ever needed. */ +#define InitialSaveTarget FreeListMin /* The number of saveareas for an initial target. This should be the minimum ever needed. */ #define InitialSaveBloks (InitialSaveAreas + sac_cnt - 1) / sac_cnt /* The number of savearea blocks to allocate at boot */ #define BackPocketSaveBloks 8 /* Number of pages of back pocket saveareas */ @@ -350,6 +350,18 @@ struct savearea_comm *save_trim_free(void); /* Remove free pages from savearea p int save_recover(void); /* returns nonzero if we can recover enough from the free pool */ void savearea_init(vm_offset_t addr); /* Boot-time savearea initialization */ +void save_fake_zone_info( /* report savearea usage statistics as 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); + +void save_snapshot(void); +void save_snapshot_restore(void); +void save_release(struct savearea *); #endif /* MACH_KERNEL_PRIVATE */ #endif /* __APPLE_API_PRIVATE */ @@ -365,6 +377,8 @@ void savearea_init(vm_offset_t addr); /* Boot-time savearea initialization */ #define SAVinstrumentb 12 /* Indicates that we should return instrumentation data */ #define SAVeat 0x00100000 /* Indicates that interruption should be ignored */ #define SAVeatb 11 /* Indicates that interruption should be ignored */ +#define SAVinject 0x00200000 /* Indicates that save_instr contains code to inject */ +#define SAVinjectb 10 /* Indicates that save_instr contains code to inject */ #define SAVtype 0x0000FF00 /* Shows type of savearea */ #define SAVtypeshft 8 /* Shift to position type */ #define SAVempty 0x86 /* Savearea is on free list */ @@ -375,3 +389,5 @@ void savearea_init(vm_offset_t addr); /* Boot-time savearea initialization */ #endif /* _PPC_SAVEAREA_H_ */ + +#endif /* XNU_KERNEL_PRIVATE */