]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ppc/savearea.h
xnu-344.21.73.tar.gz
[apple/xnu.git] / osfmk / ppc / savearea.h
index 554cd2bb8afe872f4adae9c41efb610727ffa945..6710b8eb88c1ebf276fbac75dd2fc436a88ca831 100644 (file)
@@ -3,19 +3,22 @@
  *
  * @APPLE_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.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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.
+ * 
+ * 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@
  */
 #ifdef __APPLE_API_PRIVATE
 
 #ifdef MACH_KERNEL_PRIVATE
-#include <mach/ppc/vm_types.h>
+#include <stdint.h>
+#include <mach/vm_types.h>
+
+#pragma pack(4)                                                        /* Make sure the structure stays as we defined it */
 typedef struct savearea_comm {
 
 /*
@@ -42,32 +48,35 @@ typedef struct savearea_comm {
  */
 
 
-/*     Keep the save_prev, sac_next, and sac_prev in these positions, some assemble code depends upon it to
+/*     Keep the save_prev, sac_next, and sac_prev in these positions, some assembler code depends upon it to
  *     match up with fields in saveanchor.
  */
-       struct savearea *save_prev;                                     /* The address of the previous (or next) savearea */
-       unsigned int    *sac_next;                                      /* Points to next savearea page that has a free slot  - real */
-       unsigned int    *sac_prev;                                      /* Points to previous savearea page that has a free slot  - real */
-       unsigned int    save_flags;                                     /* Various flags */
+                                                /* offset 0x000 */
+       addr64_t                save_prev;                                      /* The address of the previous (or next) savearea */
+       addr64_t                sac_next;                                       /* Points to next savearea page that has a free slot  - real */
+       addr64_t                sac_prev;                                       /* Points to previous savearea page that has a free slot  - real */
        unsigned int    save_level;                                     /* Context ID */
+       unsigned int    save_01C;
+
+                                                                                               /*       0x20 */
        unsigned int    save_time[2];                           /* Context save time - for debugging or performance */
        struct thread_activation        *save_act;              /* Associated activation  */
-
-/*                                                 0x20 */
-
-       unsigned int    sac_vrswap;                                     /* XOR mask to swap V to R or vice versa */
-       unsigned int    sac_alloc;                                      /* Bitmap of allocated slots */
+    unsigned int       save_02c;
+       uint64_t                sac_vrswap;                                     /* XOR mask to swap V to R or vice versa */
+       unsigned int    save_flags;                                     /* Various flags */
        unsigned int    sac_flags;                                      /* Various flags */
-       unsigned int    save_misc0;                                     /* Various stuff */
-       unsigned int    save_misc1;                                     /* Various stuff */
-       unsigned int    save_misc2;                                     /* Various stuff */
-       unsigned int    save_misc3;                                     /* Various stuff */
-       unsigned int    save_misc4;                                     /* Various stuff */
-
-       unsigned int    save_040[8];                            /* Fill 32 bytes */
+    
+                                                /* offset 0x040 */
+       uint64_t                save_misc0;                                     /* Various stuff */
+       uint64_t                save_misc1;                                     /* Various stuff */
+       unsigned int    sac_alloc;                                      /* Bitmap of allocated slots */
+    unsigned int       save_054;
+    unsigned int       save_misc2;
+    unsigned int       save_misc3;
 
                                                                                                /* offset 0x0060 */
 } savearea_comm;
+#pragma pack()
 #endif
 
 #ifdef BSD_KERNEL_PRIVATE
@@ -81,107 +90,91 @@ typedef struct savearea_comm {
  *     This type of savearea contains all of the general context.
  */
  
+#pragma pack(4)                                                        /* Make sure the structure stays as we defined it */
 typedef struct savearea {
 
        savearea_comm   save_hdr;                                       /* Stuff common to all saveareas */
 
        unsigned int    save_060[8];                            /* Fill 32 bytes */
-                                                                                               /* offset 0x0080 */
-       unsigned int    save_r0;
-       unsigned int    save_r1;
-       unsigned int    save_r2;
-       unsigned int    save_r3;
-       unsigned int    save_r4;
-       unsigned int    save_r5;
-       unsigned int    save_r6;
-       unsigned int    save_r7;
-       
-                                                                                               /* offset 0x0A0 */
-       unsigned int    save_r8;
-       unsigned int    save_r9;
-       unsigned int    save_r10;
-       unsigned int    save_r11;
-       unsigned int    save_r12;
-       unsigned int    save_r13;
-       unsigned int    save_r14;
-       unsigned int    save_r15;
-       
-                                                                                               /* offset 0x0C0 */
-       unsigned int    save_r16;
-       unsigned int    save_r17;
-       unsigned int    save_r18;
-       unsigned int    save_r19;
-       unsigned int    save_r20;
-       unsigned int    save_r21;
-       unsigned int    save_r22;
-       unsigned int    save_r23;
-       
-                                                                                               /* offset 0x0E0 */
-       unsigned int    save_r24;
-       unsigned int    save_r25;
-       unsigned int    save_r26;       
-       unsigned int    save_r27;
-       unsigned int    save_r28;
-       unsigned int    save_r29;
-       unsigned int    save_r30;
-       unsigned int    save_r31;
-       
-                                                                                               /* offset 0x100 */
-       unsigned int    save_srr0;
-       unsigned int    save_srr1;
+
+                                                /* offset 0x0080 */
+       uint64_t                save_r0;
+       uint64_t                save_r1;
+       uint64_t                save_r2;
+       uint64_t                save_r3;
+                                                /* offset 0x0A0 */
+       uint64_t                save_r4;
+       uint64_t                save_r5;
+       uint64_t                save_r6;
+       uint64_t                save_r7;
+                                                /* offset 0x0C0 */
+       uint64_t                save_r8;
+       uint64_t                save_r9;
+       uint64_t                save_r10;
+       uint64_t                save_r11;
+                                                /* offset 0x0E0 */
+       uint64_t                save_r12;
+       uint64_t                save_r13;
+       uint64_t                save_r14;
+       uint64_t                save_r15;
+                                                /* offset 0x100 */
+       uint64_t                save_r16;
+       uint64_t                save_r17;
+       uint64_t                save_r18;
+       uint64_t                save_r19;
+                                                /* offset 0x120 */
+       uint64_t                save_r20;
+       uint64_t                save_r21;
+       uint64_t                save_r22;
+       uint64_t                save_r23;
+                                                /* offset 0x140 */
+       uint64_t                save_r24;
+       uint64_t                save_r25;
+       uint64_t                save_r26;       
+       uint64_t                save_r27;
+                                                /* offset 0x160 */
+       uint64_t                save_r28;
+       uint64_t                save_r29;
+       uint64_t                save_r30;
+       uint64_t                save_r31;
+                                                /* offset 0x180 */
+       uint64_t                save_srr0;
+       uint64_t                save_srr1;
+       uint64_t                save_xer;
+       uint64_t                save_lr;
+                                                /* offset 0x1A0 */
+       uint64_t                save_ctr;
+       uint64_t                save_dar;
        unsigned int    save_cr;
-       unsigned int    save_xer;
-       unsigned int    save_lr;
-       unsigned int    save_ctr;
-       unsigned int    save_dar;
        unsigned int    save_dsisr;
-                       
-
-                                                                                               /* offset 0x120 */
-       unsigned int    save_vscr[4];   
+       unsigned int    save_exception; 
+       unsigned int    save_vrsave;
+                                                /* offset 0x1C0 */
+       unsigned int    save_vscr[4];
        unsigned int    save_fpscrpad;
        unsigned int    save_fpscr;
-       unsigned int    save_exception;
-       unsigned int    save_vrsave;
-
-                                                                                               /* offset 0x140 */
-       unsigned int    save_sr0;
-       unsigned int    save_sr1;
-       unsigned int    save_sr2;
-       unsigned int    save_sr3;
-       unsigned int    save_sr4;
-       unsigned int    save_sr5;
-       unsigned int    save_sr6;
-       unsigned int    save_sr7;
-
-                                                                                               /* offset 0x160 */
-       unsigned int    save_sr8;
-       unsigned int    save_sr9;
-       unsigned int    save_sr10;
-       unsigned int    save_sr11;
-       unsigned int    save_sr12;
-       unsigned int    save_sr13;
-       unsigned int    save_sr14;
-       unsigned int    save_sr15;
-
-                                                                                               /* offset 0x180 */
-       unsigned int    save_180[8];
-       unsigned int    save_1A0[8];
-       unsigned int    save_1C0[8];
+    unsigned int       save_1d8[2];
+                                                /* offset 0x1E0 */
        unsigned int    save_1E0[8];
-       unsigned int    save_200[8];
-       unsigned int    save_220[8];
-       unsigned int    save_240[8];
-       unsigned int    save_260[8];
-
+                                                /* offset 0x200 - keep on 128 byte bndry */
+    uint32_t        save_pmc[8]; 
+    uint64_t        save_mmcr0;                                        /* offset 0x220 */
+    uint64_t        save_mmcr1;
+    uint64_t        save_mmcr2;
+
+       unsigned int    save_238[2];
+                                                                                               /* offset 0x240 */
+       unsigned int    save_instr[16];                         /* Instrumentation */
                                                                                                /* offset 0x280 */
 } savearea;
+#pragma pack()
 
 
 /*
  *     This type of savearea contains all of the floating point context.
  */
  
+#pragma pack(4)                                                        /* Make sure the structure stays as we defined it */
 typedef struct savearea_fpu {
 
        savearea_comm   save_hdr;                                       /* Stuff common to all saveareas */
@@ -239,6 +232,7 @@ typedef struct savearea_fpu {
 
                                                                                                /* offset 0x280 */
 } savearea_fpu;
+#pragma pack()
 
        
 
@@ -246,6 +240,7 @@ typedef struct savearea_fpu {
  *     This type of savearea contains all of the vector context.
  */
  
+#pragma pack(4)                                                        /* Make sure the structure stays as we defined it */
 typedef struct savearea_vec {
 
        savearea_comm   save_hdr;                                       /* Stuff common to all saveareas */
@@ -289,10 +284,12 @@ typedef struct savearea_vec {
 
                                                                                                /* offset 0x280 */
 } savearea_vec;
+#pragma pack()
 #endif /* MACH_KERNEL_PRIVATE || BSD_KERNEL_PRIVATE */
 
 #ifdef MACH_KERNEL_PRIVATE
 
+#pragma pack(4)                                                        /* Make sure the structure stays as we defined it */
 struct Saveanchor {
 
 /*     
@@ -301,20 +298,24 @@ struct Saveanchor {
  *     updated with translation and interrupts disabled. This is because it is 
  *     locked during exception processing and if we were to take a PTE miss while the
  *     lock were held, well, that would be very bad now wouldn't it? 
+ *  Note that the first 24 bytes must be the same format as a savearea header.
  */
 
-       unsigned int    savelock;                               /* Lock word for savearea free list manipulation */
-       unsigned int    *savepoolfwd;                   /* Forward anchor for the free pool */
-       unsigned int    *savepoolbwd;                   /* Backward anchor for the free pool */
-       volatile unsigned int   savefree;               /* Anchor for the global free list */
-       volatile unsigned int   savefreecnt;    /* Number of saveareas on global free list */
-       volatile int    saveadjust;                             /* If 0 number of saveareas is ok, otherwise number to change (positive means grow, negative means shrink */
-       volatile int    saveinuse;                              /* Number of areas in use counting those on the local free list */
-       volatile int    savetarget;                             /* Number of savearea's needed */
-       int                             savemaxcount;                   /* Maximum saveareas ever allocated */
-
+       unsigned int                    savelock;               /* 000 Lock word for savearea free list manipulation */
+    int                                                saveRSVD4;              /* 004 reserved */
+       addr64_t                                savepoolfwd;    /* 008 Forward anchor for the free pool */
+       addr64_t                                savepoolbwd;    /* 010 Backward anchor for the free pool */
+       volatile addr64_t               savefree;               /* 018 Anchor for the global free list */
+       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 */
+       int                                             savemaxcount;   /* 030 Maximum saveareas ever allocated */
+       unsigned int                    saveRSVD034[3]; /* 034 reserved */
+/*                                                                                        040 */
 
 };
+#pragma pack()
 
 
 #define sac_cnt                (4096 / sizeof(savearea))       /* Number of saveareas per page */
@@ -332,20 +333,24 @@ struct Saveanchor {
 #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        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 */
+
+void                   save_queue(ppnum_t);            /* Add a new savearea block to the free list */
+addr64_t               save_get_init(void);            /* special savearea-get for cpu initialization (returns physical address) */
+struct savearea        *save_get(void);                        /* Obtains a savearea from the free list (returns virtual address) */
+reg64_t                        save_get_phys_32(void);         /* Obtains a savearea from the free list (returns phys addr in r3) */
+reg64_t                        save_get_phys_64(void);         /* Obtains a savearea from the free list (returns phys addr in r3) */
+struct savearea        *save_alloc(void);                      /* Obtains a savearea and allocates blocks if needed */
+struct savearea        *save_cpv(addr64_t);            /* Converts a physical savearea address to virtual */
+void                   save_ret(struct savearea *);    /* Returns a savearea to the free list by virtual address */
+void                   save_ret_wMSR(struct savearea *, reg64_t);      /* returns a savearea and restores an MSR */
+void                   save_ret_phys(reg64_t);         /* Returns a savearea to the free list by physical address */
+void                   save_adjust(void);                      /* Adjust size of the global free list */
+struct savearea_comm   *save_trim_free(void);  /* Remove free pages from savearea pool */
+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_release(struct savearea *);        /* Release a save area  */
-struct savectl *save_dequeue(void);                    /* Find and dequeue one that is all empty */
-unsigned int   save_queue(struct savearea *);  /* Add a new savearea block to the free list */
-struct savearea        *save_get(void);                                /* Obtains a savearea from the free list (returns virtual address) */
-struct savearea        *save_get_phys(void);                   /* Obtains a savearea from the free list (returns physical address) */
-struct savearea        *save_alloc(void);                              /* Obtains a savearea and allocates blocks if needed */
-struct savearea        *save_cpv(struct savearea *);   /* Converts a physical savearea address to virtual */
-void                   save_ret(struct savearea *);    /* Returns a savearea to the free list */
-void                   save_ret_phys(struct savearea *);       /* Returns a savearea to the free list */
-void                   save_adjust(void);                              /* Adjust size of the global free list */
-struct savearea_comm   *save_trim_freet(void);                 /* Remove free pages from savearea pool */
-
 #endif /* MACH_KERNEL_PRIVATE */
 #endif /* __APPLE_API_PRIVATE */
 
@@ -355,6 +360,9 @@ struct savearea_comm        *save_trim_freet(void);                 /* Remove free pages from saveare
 #define SAVrststk      0x00010000                              /* Indicates that the current stack should be reset to empty */
 #define SAVsyscall     0x00020000                              /* Indicates that the savearea is associated with a syscall */
 #define SAVredrive     0x00040000                              /* Indicates that the low-level fault handler associated */
+#define SAVredriveb    13                                              /* Indicates that the low-level fault handler associated */
+#define        SAVinstrument 0x00080000                        /* Indicates that we should return instrumentation data */
+#define        SAVinstrumentb 12                                       /* Indicates that we should return instrumentation data */
 #define SAVtype                0x0000FF00                              /* Shows type of savearea */
 #define SAVtypeshft    8                                               /* Shift to position type */
 #define SAVempty       0x86                                    /* Savearea is on free list */
@@ -362,4 +370,6 @@ struct savearea_comm        *save_trim_freet(void);                 /* Remove free pages from saveare
 #define SAVfloat       0x02                                    /* Savearea contains floating point context */
 #define SAVvector      0x03                                    /* Savearea contains vector context */
 
+
+
 #endif /* _PPC_SAVEAREA_H_ */